Skip to content

Instantly share code, notes, and snippets.

View sinewalker's full-sized avatar

Michael Lockhart sinewalker

View GitHub Profile
@sinewalker
sinewalker / wtfo.sh
Created May 13, 2019 06:40
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
sinewalker / subdir-files-completion.sh
Last active May 10, 2019 03:53
Bash completion for all files in all subdirectories of a directory
function _subfiles() {
COMPREPLY=()
local CUR FILES
CUR="${COMP_WORDS[COMP_CWORD]}"
FILES="$(find ${_COMP_DIR}/* -type f|awk -F ${_COMP_DIR}/ '{print $2}')"
COMPREPLY=( $(compgen -W "${FILES}" -- ${CUR}) )
return 0
}
@sinewalker
sinewalker / ssh.config
Created April 3, 2019 04:37
SSH jump to one host via another
Host *-via-jumpbox
ProxyCommand ssh user@jumpbox.net nc $(echo %h | sed 's/-via-jumpbox$//') %p
@sinewalker
sinewalker / chiparp.rb
Last active March 31, 2019 00:08
8-bit retro chip arp "chord" in Sonic Pi
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
sinewalker / svn-revert-awk.md
Last active February 1, 2019 00:09
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
sinewalker / ssh-add-pass.md
Last active January 23, 2019 20:49
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):
#!/bin/bash
@sinewalker
sinewalker / crashb.rb
Created December 1, 2018 23:12
crashing with the kids :)
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
end
play_pattern_timed [:F4,:F4, :r], 1
play_pattern_timed [:r,:F4], 0.5
@sinewalker
sinewalker / tainted_who.rb
Created December 1, 2018 21:00
Tainted Who
#I wanted to hear if Tainted Love and Dr. Who go together... ;-)
use_bpm 120
live_loop :metro do
tick
cue :beet
sleep 1
end
live_loop :bass, sync_bpm: :beet do
##| stop
@sinewalker
sinewalker / commandline-tools.sh
Created November 22, 2018 04:42
Re-install XCode command-line tools for Brew on macOS Mojave
/usr/bin/ruby -e "ARGV=['--force-curl'] $(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
@sinewalker
sinewalker / synpad-loops-0.rb
Last active November 16, 2018 01:59
Short rave loop
#Heard these chords somewhere on the way to work this morning, no idea what the tune was, sorry
# Anyway they gave me a bit of inspiration as I finished walking to the office, and I hacked this out
# in about 20 mins.
#
# play with the ixi/slicer fx phases, and the ixi res, and start up the bass + simple drums
#
# I found that if you wait/sleep at the end of the drum/bass loops, you'll miss the cue for the start
# of the bar, so that's why the final waits are commented out. Also if you sync at the start, it'll
# again miss the cue and wait a whole bar. Not sure best ways to resolve this -- just comment where
# they sync, I suppose.