Loading...
A template for collecting the bits of code you reach for often. Organize them by language and use case to build your own toolbox you can copy from instantly.
Collect the bits of code you use often, grouped by use case. Add a short note so each one is ready to copy and use.
Drop duplicate values in JavaScript. Using Set is the easiest way.
const unique = [...new Set(items)];Use this when you want to avoid timezone drift.
const ymd = new Date().toLocaleDateString("sv-SE");Handy for async test delays or retry intervals.
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
await sleep(1000);Test whether an object has any contents.
const isEmpty = (obj) => Object.keys(obj).length === 0;Pull file names out of a folder in Python.
from pathlib import Path
files = [p.name for p in Path("./data").glob("*.csv")]
Comments
No comments yet
Be the first to comment