Cinder Snippet Board
Git Rebase Interactive
git rebase -i HEAD~3
# In the editor change 'pick' to 'squash' for commits you want to combine3
about 2 hours agoFastAPI Hello
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def read_root():
return {"msg": "Hello World"}2
about 2 hours agoArray Shuffle (JS)
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
const nums = [1,2,3,4,5];
shuffle(nums);
console.log(nums);1
about 2 hours agoCSS Center Flex
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box {
width: 200px;
height: 200px;
background: #4f46e5;
}2
about 2 hours agoBash Loop Files
#!/usr/bin/env bash
for file in *.txt; do
echo "Processing $file"
wc -l "$file"
done3
about 2 hours agoSQL Count Users
SELECT COUNT(*) AS user_count
FROM users
WHERE created_at > now() - interval '7 days';2
about 2 hours agoGit Rebase Interactive
git rebase -i HEAD~3
# In the editor change 'pick' to 'squash' for commits you want to combine2
about 2 hours agoFastAPI Hello
from fastapi import FastAPI
app = FastAPI()
@app.get('/')
def read_root():
return {"msg": "Hello World"}2
about 2 hours agoArray Shuffle (JS)
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
}
const nums = [1,2,3,4,5];
shuffle(nums);
console.log(nums);2
about 2 hours agoCSS Center Flex
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box {
width: 200px;
height: 200px;
background: #4f46e5;
}2
about 2 hours agoBash Loop Files
#!/usr/bin/env bash
for file in *.txt; do
echo "Processing $file"
wc -l "$file"
done4
about 2 hours agoSQL Count Users
SELECT COUNT(*) AS user_count
FROM users
WHERE created_at > now() - interval '7 days';2
about 2 hours agoPython Context Manager
from contextlib import contextmanager
@contextmanager
def open_file(path, mode):
f = open(path, mode)
try:
yield f
finally:
f.close()
with open_file('example.txt', 'r') as f:
data = f.read()2
about 2 hours agoPython Context Manager
from contextlib import contextmanager
@contextmanager
def open_file(path, mode):
f = open(path, mode)
try:
yield f
finally:
f.close()
with open_file('example.txt', 'r') as f:
data = f.read()4
about 3 hours agoDebounce Function (JS)
function debounce(fn, delay) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), delay);
};
}
const log = debounce(console.log, 300);
log('Hello');
log('World');5
about 4 hours agoDebounce Function (JS)
function debounce(fn, delay) {
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => fn.apply(this, args), delay);
};
}
const log = debounce(console.log, 300);
log('Hello');
log('World');2
about 4 hours ago