Skip to content

Instantly share code, notes, and snippets.

View lrl
#!/bin/bash
set -euo pipefail
plists=()
while read -r pl; do
plists+=("${pl}")
done < <(ls ~/Library/LaunchAgents)
len=${#plists[@]}
height=$((len + 2))
View onchange
#!/usr/bin/env ruby
require('open3')
extra_fswatch_args, cmd_args = if (rest_index = ARGV.index('--'))
[ARGV[0...rest_index], ARGV[rest_index+1..-1]]
else
[[], ARGV]
end
View 0.zsh
# fragment added to ~/.zshrc
zle-gasdf() { gasdf; zle .beginning-of-line; zle .kill-line; zle .accept-line }
zle -N zle-gasdf
bindkey 'å' zle-gasdf # Alt-A Canadian English
View json_type.rb
class JSONTypeClass < T::Types::Base
ScalarType = T.type_alias { T.any(String, Numeric, NilClass, FalseClass, TrueClass) }
IterType = T.type_alias { T.any(ScalarType, T::Array[T.untyped], T::Hash[String, T.untyped]) }
def name
'JSON'
end
def valid?(obj)
# in this particular case I don't think it makes sense to distinguish
@burke
burke / 0test.rb
Created Sep 24, 2021
I'm going to hell for sure.
View 0test.rb
assert(JSONType.recursively_valid?({'a' => ['neato']}))
refute(JSONType.recursively_valid?({'a' => [:neato]}))
View 0.md

First, compile the shim:

gcc -Wall -O2 -fpic -shared -ldl bind.c -o bind.so

Now, run the demo and notice that it does what it looks like it does:

$ LD_PRELOAD=./bind.so ruby demo.rb
View 0.txt
Save this in [[roam/css]] as a toplevel block, wrapped in "```css" and "```"
View ru.nix
{ config, pkgs, lib, ... }:
{
rune.project.name = "shopify-pay";
rune.framework.rails.enable = true;
aspect.packages.include = with pkgs; [
geolite2 ngrok mysqlClient57 overmind watchman toxiproxy v8
];
rune.project.repoName = "pay";
View apfs_volume.rb
# typed: true
# frozen_string_literal: true
require('dev')
require('fileutils')
module Dev
module Helpers
class APFSVolume
extend(T::Sig)
View nix_store_safeguard.rb
# typed: false
# frozen_string_literal: true
# Note: This is loaded *ludicrously* early in the boot process: please don't
# introduce other dependencies here.
# ===
# Okay so here's the deal. When we compile a bundle of ruby code via
# `bundlerEnv`, we install all the gems individually into a bunch of separate