Skip to content

Instantly share code, notes, and snippets.

@dmcb
dmcb / srd-5.2-spells.json
Created July 6, 2025 01:16
SRD v5.2 spells for D&D 5e 2024 Edition
[
{
"name": "Acid Splash",
"level": 0,
"school": "evocation",
"classes": ["sorcerer", "wizard"],
"actionType": "action",
"concentration": false,
"ritual": false,
"castingTime": "Action",
@mjmsmith
mjmsmith / PaddingModifier.swift
Last active December 19, 2024 21:18
Padding modifier for SwiftUI views.
// NOTE: Nil values implicitly or explicitly passed as arguments to padding() are ignored.
// This differs from the built-in SwiftUI version:
//
// view.padding(trailing: nil) // has no effect
// view.padding(.trailing, nil) // resets to default
//
// See below for a version that matches the built-in behavior.
extension View {
func padding(horizontal: CGFloat? = nil, vertical: CGFloat? = nil,
//
// OCXML.swift
// Created by Marco Arment on 9/23/24.
//
// Released into the public domain. Do whatever you'd like with this.
// No guarantees that it'll do anything, or do it correctly. Good luck!
//
import Foundation
@adactio
adactio / updateDateTimes.js
Last active September 11, 2023 05:10
Periodically update the text of `datetime` elements with the relative time elapsed.
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.Intl || !win.Intl.RelativeTimeFormat) {
// doesn't cut the mustard.
return;
}
var rtf = new Intl.RelativeTimeFormat('en', {
localeMatcher: 'best fit',
numeric: 'always',
style: 'long'
@ttscoff
ttscoff / toot.rb
Last active April 28, 2023 04:58
Scans RSS feed for latest post and creates Mastodon toot
#!/usr/bin/env ruby -W1
# frozen_string_literal: true
# This script scans an RSS feed for the latest post, and if
# it hasn't already been posted to Mastodon, creates a new
# toot with a link to it.
require 'json'
require 'optparse'
require 'rss'
@chockenberry
chockenberry / ql.sh
Last active March 4, 2024 23:40
QuickLook for macOS shell
#!/bin/sh
# usage:
# ql /tmp/file.jpg
# cat /tmp/file.jpg | ql
# cal -h | ql
if [ -z "$*" ]; then
cat > /tmp/ql.stdin
mime_type=$(file --brief --mime-type /tmp/ql.stdin)
@kentcdodds
kentcdodds / session.server.ts
Created November 18, 2021 21:04
Authentication in Remix applications
import * as bcrypt from "bcrypt";
import { createCookieSessionStorage, redirect } from "remix";
import { db } from "./db.server";
export type LoginForm = {
username: string;
password: string;
};
@henrik242
henrik242 / Global macOS hotkeys for Google Meet, Spotify and others using AppleScript and Fastscripts.md
Last active April 9, 2025 22:39
Global macOS hotkeys for Google Meet, Spotify and others using AppleScript and Fastscripts

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@lancethomps
lancethomps / close_notifications_applescript.js
Last active April 27, 2025 01:40
AppleScript to close all notifications on macOS Big Sur, Monterey, Ventura, Sonoma, and Sequoia
function run(input, parameters) {
const appNames = [];
const skipAppNames = [];
const verbose = true;
const scriptName = 'close_notifications_applescript';
const CLEAR_ALL_ACTION = 'Clear All';
const CLEAR_ALL_ACTION_TOP = 'Clear';
const CLOSE_ACTION = 'Close';