Skip to content

Instantly share code, notes, and snippets.

View danielbayley's full-sized avatar

Daniel Bayley danielbayley

View GitHub Profile
@mary-ext
mary-ext / bluesky-osa.md
Last active September 24, 2025 03:46
Bluesky's age assurance sucks, here's how to work around it.

Bluesky's age assurance sucks, here's how to work around it.

Bluesky has implemented age verification measures in response to regional laws that restrict access:

  • UK users are shown a banner for attempting identity verification through Epic Games' Kids Web Services before they could access adult content, following the Online Safety Act.

  • Mississippi users are completely blocked from acccessing Bluesky due to

@holman
holman / inthunter.sh
Created June 16, 2025 21:36
inthunter
#!/bin/bash
# Get the user's global git email
user_email=$(git config --global user.email)
if [ -z "$user_email" ]; then
echo "Could not find your global git user.email. Please set it with 'git config --global user.email \"[email protected]\"'"
exit 1
fi
tmpfile=$(mktemp)
@samwho
samwho / DOM.ts
Created May 19, 2025 16:38
DOM.ts
interface ExtraOpts {
class?: string | string[];
data?: Record<string, string>;
}
type TagName = keyof HTMLElementTagNameMap;
type Tag = HTMLElementTagNameMap;
type Opts<K extends TagName> = Partial<Tag[K]> & ExtraOpts;
type Child = Node | string;
@kwikwag
kwikwag / node-engine-strict.js
Created April 29, 2025 09:31
A script that ensures your project runs with a Node.js version that satisfies the `engines.node` field in your `package.json`, using either NVM or the system-installed Node.js.
/*
# `node-engine-strict.js`
A script that ensures your project runs with a Node.js version that satisfies
the `engines.node` field in your `package.json`.
It works by checking for a compatible version installed via **NVM** (Node
Version Manager), and will fall back to the system-installed Node.js if it's
compatible. If neither is suitable, the script exits with an error.
@t3dotgg
t3dotgg / try-catch.ts
Last active September 23, 2025 08:47
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@fredrare
fredrare / NumberRange.ts
Created December 6, 2024 21:34
Small and simple generic number range implementation in TypeScript
type NextDigit = [1, 2, 3, 4, 5, 6, 7, 8, 9]
type Split<Str> = Str extends `${infer Head extends number}${infer Tail}` ? [Head, ...Split<Tail>] : []
type Increase<X extends number[]> = X extends [...infer Rest extends number[], infer Last extends number] ?
Last extends 9 ? [...Increase<Rest>, 0] : [...Rest, NextDigit[Last]]
: [1]
type TupleToString<T extends number[]> =
T extends [infer First extends number, ...infer Rest extends number[]]

Ruby: The future of frozen string literals

What is a literal?

In programming languages, literals are textual representations of values in the source code. This is a syntactical concept.

Some examples:

7 # integer literal
@danielbayley
danielbayley / seticon.swift
Created February 25, 2023 15:27
Set icon for file or folder from image, existing app or folder.
#! /usr/bin/xcrun swift
import Cocoa
let args = CommandLine.arguments[1...]
let (target, icon) = (URL(fileURLWithPath: args.first!).path, args[2])
var folder: ObjCBool = false
FileManager.default.fileExists(atPath: icon, isDirectory: &folder)
let image: NSImage = folder.boolValue
@kaizhu256
kaizhu256 / globExclude.mjs
Last active June 29, 2024 01:21
This gist file demos a performant, self-contained function "globExclude()", which batch-globs <pathnameList> in a single pass, with given filters <excludeList>, <includeList>.
/*jslint beta, node*/
// This gist file demos a performant, self-contained function "globExclude()",
// which batch-globs <pathnameList> in a single pass,
// with given filters <excludeList>, <includeList>.
//
// Could be useful if you need to glob thousands of files for test-coverage,
// or other purposes.
// Example usage