Skip to content

Instantly share code, notes, and snippets.

@mrdomino
mrdomino / org.wholezero.watchpath.plist
Last active January 16, 2024 20:10
kill zsh with USR1 every time a path directory changes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.wholezero.watchpath</string>
<key>ProgramArguments</key>
<array>
<string>/bin/zsh</string>
<string>-lc</string>
@mrdomino
mrdomino / rc.h
Last active March 13, 2024 23:37
#pragma once
#include <cassert>
#include <cstdint>
#include <exception>
#include <new>
#include <type_traits>
#include <utility>
namespace detail {
@mrdomino
mrdomino / zwatch.sh
Last active March 5, 2022 06:23
rsync source with destination every time any change occurs in source
#!/bin/sh
set -eu
trap "echo 'usage: $0 <pier> <base> [desk]' >&2" EXIT
pier=$1
base=$2
if [ 3 -eq $# ]; then
desk=$3
else
desk=base
fi
#!/usr/bin/env python3
import fileinput
import re
def main():
for line in fileinput.input():
if not re.search(r'^[0-9a-fA-F]+$', line):
continue
print('0x', end='')
line = line.strip().lstrip('0')
@mrdomino
mrdomino / patp.js
Created October 21, 2021 07:56
print 16 random @ps under a given star
// requires urbit-ob
const ob = require('urbit-ob');
const crypto = require('crypto');
const STAR = '~binzod';
const STAR_HEX = ob.patp2hex(STAR);
for (var i = 0; i < 16; ++i) {
const byt = crypto.randomBytes(2).toString('hex');
console.log('0x' + byt + '.' + STAR_HEX, ob.hex2patp(byt + STAR_HEX));
@mrdomino
mrdomino / chrome
Created December 31, 2016 23:16
OpenBSD script to run chrome as a separate user in a Xephyr window
#!/bin/sh
set -eux
NDISPLAY=:13
if [ $# -ge 1 ]
then
case $1 in
:*)
NDISPLAY=$1
shift
@mrdomino
mrdomino / browse.sh
Created December 5, 2016 14:40
run firefox as a separate user in openbsd
#!/bin/sh
set -eu
tmpfile=$(mktemp)
xauth -q -f $tmpfile generate $DISPLAY . untrusted
xauth_data=$(xauth -f $tmpfile nlist $DISPLAY)
rm -f $tmpfile
DOAS_XAUTH="xauth -q remove $DISPLAY ; echo $xauth_data | xauth nmerge - ;"
export DOAS_XAUTH
#include <stdio.h>
int main() {
while (1) puts("whee");
}
#!/bin/sh
# usage: flag <flag> [args...]
# e.g.: flag --foo= x y z
# --foo=x --foo=y --foo=z
trap "awk '/^# /' $(which $0) | cut -d' ' -f2-" EXIT
set -eu; flag=$1; shift; for arg in "$@"; do echo $flag$arg; done
exec true
#!/bin/sh
exec git $@