Skip to content

Instantly share code, notes, and snippets.

@ciiqr
ciiqr / zod-optional-null.ts
Last active October 15, 2025 19:24
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@jaredh159
jaredh159 / noop-proxy.js
Created January 10, 2019 20:09
lol no-op object proxy
const noop = new Proxy({}, {
get(target, prop, receiver) {
const fn = () => receiver;
Object.setPrototypeOf(fn, receiver);
return fn;
},
});
// allows you to infinitely call methods and access properties that don't exist:
console.log(noop.foo.baz().bar.jim().jam().lol); // <-- no errors!
@rina-andria
rina-andria / donut-chart-with-labels.json
Created August 16, 2018 12:35
Vega Donut Chart with Label
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 300,
"height": 300,
"autosize": "pad",
"signals": [
{"name": "startAngle", "value": 0},
{"name": "endAngle", "value": 6.29},
{"name": "padAngle", "value": 0},
{"name": "sort", "value": true},
Diff:
C:\Program Files\Perforce\p4merge.exe -nl %bname -nr %yname %base %mine

Merge:
C:\Program Files\Perforce\p4merge.exe -nb %bname -nl %tname -nr %yname -nm %mname %base %theirs %mine %merged
@mshafrir
mshafrir / states_hash.json
Created May 9, 2012 17:05
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AS": "American Samoa",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r