Random snippets of all sorts of code, mixed with a selection of help and advice.
I found two solutions on how to generate points on a circle, within two radius values. One solutions favors the center, one does not. Why is this so?
19 April 2026 @ 4:34 pm
There was a Reddit post about generating points randomly in a circle, where the points are constrained between two radius bounds, minRadius and maxRadius. The formula to generate a point from an origin (x', y'), a radius r and angle a is:
x = x' + r*cos(a)
y = y' + r*sin(a)
There we two solutions presented. For the first solution, people said that points generated will favor the center, and so a second solution was presented where the points will be distributed evenly. I will write the two solutions below
I want to understand why the first solution produces points towards the middle, and why the second one does not
The first solution is:
function get_point_in_circle(x',y',minRadius,maxRadius)
{
var a = random(360);
var r = random_range(minRadius,maxRadius);
return {
x : x' + r * cos(a),
y : y' + r * sin(a),
}
}
The o
How can I get vscode recent file/folder/workspaces on linux with cli tools or via code?
19 April 2026 @ 4:25 pm
I use powertoys-run on my windows machine which provides vscode recent workspaces (including folders) search results. Currently I use archlinux with hyprland on my laptop, and I want to someway get this experience on linux, too, either by invoke some cli tools in shell scripts and run them in a dmenu-like launcher (like rofi), or by write some rust code in a launcher called zlaunch. But how can I get this done? How can I get a list of recently opened workspaces/files/folders?
Is there a way to bypass this restriction [closed]
19 April 2026 @ 4:23 pm
I have created this python script for auto typing the given content at a certain typing speed(since copy and paste is blocked). They updated the browser now it blocks the python.exe the compiler, which will get activated while running the script. So is there any way I can bypass this restriction.
Cannot remove role from postgres
19 April 2026 @ 4:19 pm
Can't delete a role in Postgres.
postgres=# \c test_database;
drop role user1;
ERROR: role "user1" cannot be dropped because some objects depend on it
DETAIL: privileges for schema public
owner of default privileges on new sequences belonging to role user1 in schema public
owner of default privileges on new relations belonging to role user1 in schema public
I issue this command:
SELECT
pg_get_userbyid(defaclrole) AS owner,
nspname AS schema,
defaclobjtype AS type,
defaclacl AS privileges
FROM pg_default_acl a
LEFT JOIN pg_namespace b ON a.defaclnamespace = b.oid
WHERE pg_get_userbyid(defaclrole) = 'user1';
I get:
owner | schema | type | privileges
------------+--------+------+-----------------------
user1 | public | S | {backup=r/confluence}
user1 | public | r | {backup=r/confluence}
Help please.
Display status bar in android app using Unity
19 April 2026 @ 4:16 pm
I'm new to app development and have a question regarding the UI. I'm using Unity 6.4 and its UI Toolkit.
I want my android app both to display the status bar (on top) and the navigation bar (at the bottom), similar to this screenshot:
For the navigation bar, I found the correct setting in the player settings:
However I don’t know how to display the status bar. When searching online, I found some threads from previous Unity Versions saying that plugins are needed or alternatively scripts (which seem to be incompatible with Unity 6.4 and the newest android versions though).
Thank you very much for your help.
PS: I hope crossposting is ok if the other post wasn't answered
For the navigation bar, I found the correct setting in the player settings:
However I don’t know how to display the status bar. When searching online, I found some threads from previous Unity Versions saying that plugins are needed or alternatively scripts (which seem to be incompatible with Unity 6.4 and the newest android versions though).
Thank you very much for your help.
PS: I hope crossposting is ok if the other post wasn't answeredGame Engine Design - Dependency Injection vs Service Locator
19 April 2026 @ 4:14 pm
I've been working on an ECS game engine using the EnTT library. I've tried to stick to the following design rules:
Components are purely structs
Systems are collections of functions (not classes)
If a system needs a state, it will have a Context struct to contain global state
Here's an example of what it would look like in practice
namespace PhysicsSystem {
struct Context {
float gravity;
// global physics state...
}
struct Component {
float mass;
// properties of physics component...
}
// Perform single physics simulation step for a component
void PhysicsStep(Context &ctx, Component &component);
}
void main() {
entt::registry registry;
// Create Context instance within EnTT Registry
Phy
How to correctly split this SDL3 Hello, World! program into separate modules?
19 April 2026 @ 4:01 pm
If I understand correctly, one way to organise C++ code is to separate it into modules. For example, one module for the SDL3 call backs and another for internal functions.
Here is the main call back module hello.cpp:
#include "hello.h"
/* This function runs once at startup. */
SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) { //NOLINT
SDL_Window *window = nullptr;
SDL_Renderer *renderer = nullptr;
/* Create the window */
if (!SDL_CreateWindowAndRenderer("Hello, World!", WIDTH, HEIGHT,
SDL_WINDOW_FULLSCREEN, &window, &renderer)) {
SDL_Log("Couldn't create window and renderer: %s", SDL_GetError()); //NOLINT
return SDL_APP_FAILURE;
}
*appstate = renderer;
return SDL_APP_CONTINUE;
}
/* This function runs when a new event (mouse input, keypresses, etc) occurs. */
SD
Firebase generate private key issue
19 April 2026 @ 3:38 pm
enter image description here
i create cross platform mobile application on which i want to integrate firebase but while trying to get private key it shows Key creation is not allowed on this service account. Please check if service account key creation is restricted by organization policies.
i tried with cloud console to override the parent policy but can't able to resolve this issue
help me if anybody have idea
Find the Maximum Value in a Vector Array using Recursion
19 April 2026 @ 3:15 pm
I am asked to do:
int maxVal(const vector& arr, int i = 0)
Using recursion only no Loops
I have the idea that I have to compare each element i But I confused how this idea should be converted into recursive calls.
This is my code:
#include <iostream>
#include <vector>
using namespace std;
int maxVal(const vector<int> &arr, int i)
{
if (i > arr.size() - 1)
{
return 1;
}
return (maxVal(arr, i + 1) > arr[i]);
}
int main()
{
vector<int> arr = {3, 7, 1, 9, 4, 6, 2};
cout << "Max Value (Using Recursion) = " << maxVal(arr, 0);
return 0;
}
I've made a JWT service and I yet have to solve the authorization issue with my attendance controller in the Web API layer what's the solution?
19 April 2026 @ 9:21 am
I'm working on an ASP.NET Core Web API with JWT authentication. I generate a token that includes a custom claim EmployeeId, and I try to read it inside my controller, but it is always returned as null or 0.
JWT generation (JwtService):
public string GenerateAccessToken(User user, IEnumerable<string> roles, IEnumerable<string> permissions, int employeeId)
{
var secretKey = _config["Jwt:Key"] ?? "I_AM_2026";
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
var claims = new List<Claim>
{
new Claim(ClaimTypes.Name, user.Username),
new Claim("UserId", user.Id.ToString()),
new Claim("EmployeeId", employeeId.ToString())
};
if (roles != null && roles.Any())
claims.AddRange(roles.Select(role => new