Skip to content

Instantly share code, notes, and snippets.

View sinewalker's full-sized avatar

Michael Lockhart sinewalker

View GitHub Profile
@sinewalker
sinewalker / _gitmux_filter.sh
Last active September 1, 2022 07:36
gitmux filter to replace 'origin' with a symbol for the git host.
#!/usr/bin/env bash
# Wrapper for gitmux to change some strings in ways that it doesn't
# allow for. Also replace 'origin' with a symbol for the git host.
WORKING_COPY=${1}
[[ -d ${WORKING_COPY} ]] || exit 1
pushd $WORKING_COPY &> /dev/null
STATUS=$(git status) &> /dev/null || exit 2
URL=$(git config --get remote.origin.url) &> /dev/null
if [[ "${STATUS}" =~ "No commits yet" ]] ; then
@sinewalker
sinewalker / envutils.py
Created June 17, 2021 20:58 — forked from vlasovskikh/envutils.py
Source Bash file using a Python function
import os
from subprocess import Popen, PIPE
import pickle
PYTHON_DUMP_ENVIRON = """\
import sys
import os
import pickle
@sinewalker
sinewalker / sonic-pi-snippets.md
Last active March 25, 2021 00:57
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: sonic-pi-net/sonic-pi#587

Specifically, Sam's comment: sonic-pi-net/sonic-pi#587 (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:

load_snippets("/path/to/snippets/dir")

live_loop :india do
use_random_seed 4000
16.times do
sample "tabla_", choose
sleep 0.125
end
sample "tabla_", choose
sleep 0.125
2.times do
sample "tabla_", choose
@sinewalker
sinewalker / bootusb-mac.md
Last active July 12, 2019 04:58
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
sinewalker / freezenv.sh
Created May 21, 2019 02:16
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
fi
@sinewalker
sinewalker / minecraft-coords.md
Created May 18, 2019 22:54
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
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