Skip to content

Instantly share code, notes, and snippets.

Michael Lockhart sinewalker

Block or report user

Report or block sinewalker

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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
sinewalker /
Last active Feb 1, 2019
Revert all deleted files in SVN

SVN doesn't seem to let you revert multiple files with a wildcard (or say if you deleted a whole directory tree in error)?

This works:

svn status|awk '/^D/{system("svn revert " $2)}'

There's probably another way....

sinewalker /
Last active Jan 3, 2019
ssh-pass: add an SSH key to your agent with passphrase from password store, no clipboard
#Add specified SSH keys to the SSH Agent, using SSH_ASKPASS to retrieve
#each key's passphrase from the Unix password store (pass).
#This relies upon the keys having the same names in both your key directory
#and your password store.
if [[ -z ${1} ]]; then
echo "$(basename ${0}): no SSH key specified" 1>&2
exit 1;
sinewalker /
Last active Jan 23, 2019
Get passphrase for an SSH key from password store, securely

This should be a blog post, and I'll make it one when I have more than 5 mins to spare. For instance these examples are hard-coded for my github SSH key, rather than parameterised.

Based on this SO question

Rather than use pass -c to copy an SSH key passphrase to your system clipboard and then paste it at the ssh-askpass prompt (which is not very secure: any program can read the clipboard), you can use an SSH_ASKPASS script to retrieve the passphrase from password store and give it to ssh-add.

  1. Make a script that retrieves the passphrase from pass (which in turn will prompt for a master passphrase if needed, via GnuPG PinEntry):
sinewalker / crashb.rb
Created Dec 1, 2018
crashing with the kids :)
View crashb.rb
use_bpm 150
use_synth :tech_saws
live_loop :crash do
2.times do
play_pattern_timed [:C4,:r,:C4,:F4, :G4,:C5,:r,:Bb4], 0.5
play_pattern_timed [:r,:G4,:r,:G4, :Gb4,:G4,:Gb4,:G4], 0.5
play_pattern_timed [:F4,:F4, :r], 1
play_pattern_timed [:r,:F4], 0.5
You can’t perform that action at this time.