Skip to content

Instantly share code, notes, and snippets.

View LukeberryPi's full-sized avatar

LukeberryPi LukeberryPi

View GitHub Profile
@LukeberryPi
LukeberryPi / generateRandomHexcode.js
Created October 20, 2023 22:02
function to generate a random hexcode
function generateRandomHexCode() {
const validChars = "abcdef0123456789";
let hexcode = "#";
for (let i = 0; i < 6; i++) {
const char = validChars[Math.floor(Math.random() * validChars.length)];
hexcode += char;
}
return hexcode;
@LukeberryPi
LukeberryPi / index.html
Created October 20, 2023 22:16
how to justify three elements in a container and keep the middle one centered regardless of children size
<div class="flex justify-between">
<div class="flex flex-1 justify-start">huuuuuuuuuuuuge left element</div>
<div class="flex flex-1 justify-center">center element</div>
<div class="flex flex-1 justify-end">right element</div>
</div>
@LukeberryPi
LukeberryPi / main.py
Created October 22, 2023 23:01
a python program to select chords in a harmonic field
import random as rd
random = rd
tom = ['A','B','C','D','E','F','G']
number_chords = [3,4,5]
tom_a = ['A','Bm','C#m','D','E','F#m']
tom_b = ['B','C#m','D#m','E','F#','G#m']
tom_c = ['C','Dm','Em','F','G','Am']
tom_d = ['D','Em','F#m','G','A','Bm']
@LukeberryPi
LukeberryPi / romanToInteger.js
Created October 25, 2023 00:19
roman to integer javascript function
function romanToInteger(roman) {
const romanNumerals = {
I: 1,
V: 5,
X: 10,
L: 50,
C: 100,
D: 500,
M: 1000,
};
@LukeberryPi
LukeberryPi / tailwind.txt
Created October 30, 2023 17:02
tailwind octopost
tailwind octopus
what tailwind is
a map of css properties
classes that have objective names and purposes
what tailwind isn’t
bootstrap
is a component library
one class in bootstrap is equivalent to hundreds of opinionated css properties
@LukeberryPi
LukeberryPi / settings.json
Last active November 17, 2023 22:53
disable all italics vscode
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"comment",
"comment.block",
"comment.block.documentation",
"comment.line",
"constant",
"constant.character",
@LukeberryPi
LukeberryPi / benchmark.js
Created November 20, 2023 16:19
benchmark function for comparing performances in javascript
function benchmark(testName, callback) {
const startTime = performance.now();
callback();
const endTime = performance.now();
console.log(testName, `time: ${endTime - startTime}`);
}
// usage
function addNums(a, b) {
@LukeberryPi
LukeberryPi / loops.js
Last active November 21, 2023 21:16
comparing loops in javascript
function benchmark(testName, callback) {
const startTime = performance.now();
callback();
const endTime = performance.now();
console.log(testName, `time: ${endTime - startTime}`);
}
const nums = Array(1000).fill(1);
function iterateWithMap(nums) {
@LukeberryPi
LukeberryPi / setup.md
Created November 23, 2023 22:04
get borderless arc
@LukeberryPi
LukeberryPi / shuffle.js
Created November 26, 2023 18:41
fisher-yates/knuth shuffle in javascript
function shuffle(arr) {
for (let i = 0; i < arr.length - 1; i++) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
}
return arr;
}