Sunday, March 8, 2026

Code Math: Sine as pseudo 1D noise generator

Lets use sine as a randomness provider to generate a infinite sequence of random numbers that change smoothly with no state:

1. Step wave that grows from 0-1 and resets back to 0 again every 1:

step(x) = ((x % 1) + 1) % 1

2-3. The random number generator from the last post:

random(x) = sin(floor(x) ** 3)

4. Interpolate between the current random number and the next:

noise(x) = step(x) * random(x + 1) + (1 - step(x)) * random(x)

5. Combine multiple sequences of different frequencies and amplitudes:

noise(x) + noise(x * 2) / 2 + noise(x * 4) / 4 + noise(x * 8 ) / 8

Graph of each:



done_

Code Math: Sine as pseudo random number generator

Lets use sine as a randomness provider to generate a infinite sequence of random numbers with no state:

1. Sine wave: 

sin(x)

2. Sample the wave by an non linear expression in order to avoid the linear repeat pattern of the sine: 

sin(x ** 3)

3. Extract only the values at integer points that represent the indexes of the random numbers in the sequence: 

sin(floor(x) ** 3)

4. Map the optional seed to the 0-1 range and added multiplied by 2PI in the sample location: 

sin((floor(x) + seed * 2 * Math.PI) ** 3)

Graph of each:



done_

Wednesday, March 4, 2026

Clipboard: The copy lie

You select a piece of text, right-click and select Copy. As the name suggests, you have now have a copy of the text in the copy vault (or clipboard if you prefer) untill the computer dies.

Now the lie, if you do the same with a file, you dont get a copy in the copy vault. You get a copy to the file path and when you do a paste, then and only then a copy is created.

It the simple case, everything works, but if the "marked for copy in the future" file is deleted or the system has no longer access to it, instead of a copy you get an error on paste.

If you wanted to actual make a copy, you could make a hardlink if the files is on a physical filesystem, create an actuall copy in memory if the file is small, or just create an actual copy in worst case.

But the problem is not that fake copy is default, the problem is that there is not an option for the actual copy. Bellow the Copy option should be a 'Copy for real' option.



next_

Tuesday, January 27, 2026

Bash: Custom keyboard shortcuts

Are you bored of typing ls all the time in your terminal. Wouldn't be greate if you could just hit a shortcut? You are in luck, because you just can. No addon, no nothing, just with the built-in bind:

bind '"\el":"ls -thor\n"'

Here you just bind Alt-L to run ls -thor.



done_