Skip to content

Instantly share code, notes, and snippets.

View sinewalker's full-sized avatar

Michael Lockhart sinewalker

View GitHub Profile
@sinewalker
sinewalker / fix-id3s.py
Created April 26, 2017 09:14
use eyed3 to set ID3 tags on MP3 files
# I used this code within an IPython session to clean up all the missing ID3 tags from my MP3 collection.
# They had gone missing years ago when I down-sampled them to fit on an old phone, and then lost the originals.
# Fortunately I named the files themselves with the basic details (artist, date, title and so on) so it was possible to
# recover the tags... It sat on my to-do list for *years* but now I finally did it.
# I used the Python library "EyeD3" (get it?): https://pypi.python.org/pypi/eyeD3
# This requires Python 2.7, which has some interesting quirks for Unicode, a bit of a pain since I had named my MP3s
# with utf8 characters. What I've come up with *mostly* works. When it doesn't I had to resort to manually editing (using
# Clementine).
@sinewalker
sinewalker / compositing.md
Created March 9, 2018 23:30
Toggle compositing in KDE

qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.active

Gives you true or false depending on whether it is currently enabled or not

You can enable compositing by calling

qdbus org.kde.KWin /Compositor org.kde.kwin.Compositing.resume

and disable by calling

@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 / check-required-utilities.sh
Last active May 18, 2021 00:40
Checking a bash script's requirements are met by the host OS
# required utilities
required=(
grep
awk
curl
jq
)
missing=()
@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")

@sinewalker
sinewalker / sticks.bas
Last active May 25, 2020 21:10
Pick-up Sticks: early 8-bit graphics hack (BASIC)
5 REM This is for Amstrad CPC Locomotive BASIC
10 CLS
20 WHILE 1>0
30 GRAPHICS PEN 15*RND
40 MOVE 640*RND,400*RND
50 DRAW 640*RND,400*RND
60 WEND
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 / irish-cream.md
Last active July 20, 2019 10:51
Whiskey Cream

Whiskey Cream

Per batch (about 870ml)

  • 1 teaspoon unsweetened cocoa powder
  • 1 teaspoon instant coffee powder
  • 1 cup (235 ml) thickened/whipping cream
  • 1 (400 ml) can sweetened condensed milk
  • ½ teaspoon vanilla extract
@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