Skip to content

Instantly share code, notes, and snippets.

@zzzarius
zzzarius / git-push-current-branch.sh
Created June 4, 2025 06:48
Git push current branch by making it upstream too
git push -u origin $(git branch --show-current)
declare const brand: unique symbol;
type Brand<T, Brand extends string> = T & { [brand]: Brand };
@zzzarius
zzzarius / autocomplete.ts
Created May 16, 2025 15:19
Typescript autocomplete
type MyStrings =
| 'One'
| 'Two'
| (string & {});
const mystring: MyStrings = "this will not error and autocomplete will still work";
@zzzarius
zzzarius / NoInfer.ts
Last active May 8, 2025 10:15
NoInfer utility for older TypesScript versions
type NoInfer<T> = [T][T extends any ? 0 : never]
@zzzarius
zzzarius / biome.json
Created May 5, 2025 07:06
Biome config
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": []
@zzzarius
zzzarius / neverthrow.js
Last active April 22, 2025 12:14
Cleaner error handling using `never throw` pattern
type OK<T> = {
data: T
err: null
}
type Fail<E> = {
data: null
err: E
}
@zzzarius
zzzarius / iterpolation.js
Created December 4, 2024 20:51
Interpolate string template js
const interpolate = function(template, params) {
const names = Object.keys(params);
const vals = Object.values(params);
return new Function(...names, `return \`${template}\`;`)(...vals);
}
@zzzarius
zzzarius / get-schema.sh
Last active September 25, 2024 10:39
Get graphql schema from Contentful
npm install -g graphqurl
gq https://graphql.contentful.com/content/v1/spaces/<space_id>/environments/<environment_name> -H 'Authorization: Bearer <CONTENTFUL_ACCESS_TOKEN>' --introspect > schema.graphql
[...Array(100).keys()]
// Output: [0, 1, 2, 3, ..., 98, 99]
import { EntrySys } from "@contentful/app-sdk";
import { EntryMetaSysProps } from "contentful-management";
export const EntryStatus = {
ARCHIVED: "archived",
PUBLISHED: "published",
CHANGED: "changed",
DRAFT: "draft",
} as const;