Skip to content

Instantly share code, notes, and snippets.

View gkucmierz's full-sized avatar
💻

Grzegorz Kućmierz gkucmierz

💻
View GitHub Profile
// https://www.youtube.com/live/H7jdq0elNoY?si=NNHutyJiNx5E8IPz&t=2085
// it is not possible to link this gist on youtube, bcs their links policy,
// so linked this gist with YT video
import { canvas, onResize } from 'canvas';
import { mobius } from '@gkucmierz/utils@3.2.0';
const ctx = canvas.getContext('2d');
// --- Configuration Constants ---
import { canvas, onResize } from 'canvas';
import { mobius } from '@gkucmierz/utils@3.2.0';
const ctx = canvas.getContext('2d');
// --- Configuration Constants ---
const BG_COLOR = '#0f172a'; // Background color of the canvas (Slate 900)
const MAX_X = 250;
const MAX_Y = 0; // Maximum limit on Y axis (set to 0 or -1 for auto-scaling)
const STEP_X = 20; // Grid step size for X axis (set to 0 for auto-scaling)
import { canvas, onResize } from 'canvas';
const ctx = canvas.getContext('2d');
onResize((width, height) => {
// Adjust drawing buffer size to match splitter dimensions
canvas.width = width;
canvas.height = height;
// 1. Background - elegant, dark navy (cyber-dark style)
ctx.fillStyle = '#090d16';
import { factorsBI, arrayHistogram } from '@gkucmierz/utils';
const generatePin = () => {
return Math.trunc(Math.random() * 1e6).toString().padStart(6, '0');
}
for (let i = 0; i < 10; ++i) {
const pin = generatePin();
const csum = detSigDig(pin);
console.log(pin, csum);
const LagDetector = (() => {
let run = true;
const TRESHOLD = 1e3/60 + 1; // ~60 FPS
let lastTime = +new Date();
(function loop() {
const time = +new Date();
const diff = time - lastTime;
if (diff > TRESHOLD) {
console.log(`Interface blocked for ${diff}ms`);
@gkucmierz
gkucmierz / maze-creatated-with-llm.js
Last active May 20, 2026 04:56
maze-creatated-with-llm.js Run this code instantly in your browser: http://localhost:5026/gist/8134f76fe134332605b74a0f652e0bab Run this code instantly in your browser: https://instacode.app/gist/8134f76fe134332605b74a0f652e0bab
/* --------------------------------------------------------------
Labirynt
Otwarcie: górna krawędź po prawej → wejście
dolna krawędź po lewej → wyjście
Unikalny szlak od wejścia do wyjścia → perfekcyjny labirynt
-------------------------------------------------------------- */
const labW = 38; // szerokość (liczba pól)
const labH = 18; // wysokość (liczba pól)
@gkucmierz
gkucmierz / bootable-win-on-mac.md
Created October 2, 2025 05:12 — forked from acarril/bootable-win-on-mac.md
Create a bootable Windows USB using macOS

For some reason, it is surprisingly hard to create a bootable Windows USB using macOS. These are my steps for doing so, which have worked for me in macOS Monterey (12.6.1) for Windows 10 and 11. After following these steps, you should have a bootable Windows USB drive.

1. Download a Windows disc image (i.e. ISO file)

You can download Windows 10 or Windows 11 directly from Microsoft.

2. Identify your USB drive

After plugging the drive to your machine, identify the name of the USB device using diskutil list, which should return an output like the one below. In my case, the correct disk name is disk2.

const TIMES = 1e7;
const STR = 'This project was realized as part of my article';
const replace = [
str => str.replaceAll(' ', '-'),
str => str.replace(/ /g, '-'),
str => str.replace(/\W/g, '-'),
];
// https://projecteuler.net/problem=57
const squareRoot = n => {
const STEPS = 100;
let res = 0;
for (let i = 0; i < STEPS; ++i) {
res = (n-1) / (2 + res);
}
return res + 1;
};
const M = (n, verbose = false) => {
const steps = n - 2;
const prime = 2n ** BigInt(n) - 1n;
verbose && console.log('prime: ', prime);
let s = 4n;
for (let i = 0; i < steps; ++i) {
s = (s ** 2n - 2n) % prime;
verbose && console.log(i, s);
}