Skip to content

Instantly share code, notes, and snippets.

@miguelgrinberg
miguelgrinberg / undercurl
Created July 27, 2023 23:17
Tiny script to test if the undercurl control codes work in your terminal.
#!/bin/bash
printf 'This is \e[4:3mmono undercurl\e[0m,\n'
printf 'and this is \e[4:3m\e[58:2:206:64:51mcolor undercurl\e[0m.\n'
@miguelgrinberg
miguelgrinberg / fibo.js
Last active February 24, 2025 08:54
Fibonacci benchmark
const fibo = n => {
if (n <= 1) {
return n;
}
else {
return fibo(n-1) + fibo(n-2);
}
}
for (let n of process.argv.slice(2)) {
@miguelgrinberg
miguelgrinberg / bubble.js
Last active November 18, 2024 11:43
Bubble sort benchmark
const bubble_sort = (arr) => {
const n = arr.length;
for (let i = 0; i < n; i++) {
for (let j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
}
}
}
return arr;