Skip to content

Instantly share code, notes, and snippets.


Michael Lockhart sinewalker

View GitHub Profile
sinewalker /
Last active Mar 25, 2021
How to use Sonic Pi Snippets

Sonic Pi has an experimental, undocumented feature to support snippets, which autoexpand with the TAB key.

Here's the issue:

Specifically, Sam's comment:

... [T]o play with it now (with the caveat that it all may drastically change) you just need to create a file with the contents of your snippet with an .sps extension in a directory somewhere on your machine. You might want to create a snippets directory for your own personal snippets. The name of the file doesn't matter. You then load all the snippets in a given directory with:


View bollybyte.rb
live_loop :india do
use_random_seed 4000
16.times do
sample "tabla_", choose
sleep 0.125
sample "tabla_", choose
sleep 0.125
2.times do
sample "tabla_", choose
sinewalker /
Last active Jul 12, 2019
Make a bootable USB from an ISO image, on macOS

Making a bootable USB on a Mac

  1. hdiutil convert -format UDRW -o bootimage.img sourceimage.iso
  2. diskutil list (look for the volume that's the same size as your USB device. It'll be "external".)
  3. diskutil partitionDisk /dev/diskX 1 "Free Space" "unused" "100%" (use diskX from the list!)
  4. sudo dd if=bootimage.img of=/dev/diskX bs=1m

original source

sinewalker / slack-dark.css
Created May 26, 2019
Slack Desktop Dark Theme CSS
View slack-dark.css
Activate by appending this code to the end of ~\AppData\Local\slack\app-3.3.8\resources\app.asar.unpacked\src\static\ssb-interop.js
document.addEventListener('DOMContentLoaded', function() {
url: '',
success: function(css) {
sinewalker /
Created May 21, 2019
Freeze your python pip requirements to a known place, to guard against Homebrew mess-ups
freezenv() {
FUNCDESC='Freeze the active Python Environment pip requirements.
This stores the requirements.txt in the active $VIRTUAL_ENV or $CONDA_PREFIX
directory, overwriting any existing requirements file.'
if [[ -z ${VIRTUAL_ENV-$CONDA_PREFIX} ]] ; then
error "$FUNCNAME: no active python or conda venv"
return 1
sinewalker /
Created May 18, 2019
Minecraft Pi Edition Python Coords vs Minecraft Debugging Coords

To fix your Minecraft world so that the coordinates displayed on the F3 debugging screen match what the MCPI API tells you with player.getPos() or player.getTilePos(), issue this Command in the game (requires Multiplayer, or a World generated with Cheat Codes enabled):

/setworldspawn 0 0 0

(to do this, press T or / and then type /setw followed by the TAB key, and then 0 0 0. For some reason you can't type this command out in full on the Talk window.)

sinewalker /
Created May 13, 2019
wtfo -- fix wtf -o option's error message when it can't find an abbreviation
function wtfo(){
FUNCDESC="Look up an abbreviation, including obscene meanings"
wtf -o ${@}|sed 's/nothing appropriate/nothing inappropriate/'
sinewalker /
Last active May 10, 2019
Bash completion for all files in all subdirectories of a directory
function _subfiles() {
FILES="$(find ${_COMP_DIR}/* -type f|awk -F ${_COMP_DIR}/ '{print $2}')"
COMPREPLY=( $(compgen -W "${FILES}" -- ${CUR}) )
return 0
sinewalker / ssh.config
Created Apr 3, 2019
SSH jump to one host via another
View ssh.config
Host *-via-jumpbox
ProxyCommand ssh nc $(echo %h | sed 's/-via-jumpbox$//') %p
sinewalker / chiparp.rb
Last active Mar 31, 2019
8-bit retro chip arp "chord" in Sonic Pi
View chiparp.rb
define :chiparp do |notes, duration, c_amp=0.8, c_Hz=30, c_sust_ratio=1, c_step=1|
tx=bt(1) # seconds for 1 beat
in_thread do
use_bpm 60 # normalise bpm to 1 beat per second
c_speed = 1.0/c_Hz #the chip speed is better converted from Hz
count = (duration * tx / c_speed)
use_synth :chiplead
use_synth_defaults amp: c_amp, sustain: c_speed*c_sust_ratio,
attack: 0, decay: 0, release: 0