Skip to content

Instantly share code, notes, and snippets.

Jamie Bainbridge superjamie

View GitHub Profile
superjamie / failsafe-walk.txt
Last active Dec 30, 2017
Walkthrough for Fail-Safe by Jon Ingold (2000)
View failsafe-walk.txt
Walkthrough for Fail-Safe by Jon Ingold (2000)
frotz FailSafe.z5
connect blue and green wires
press reset
superjamie /
Created Aug 21, 2016 — forked from unbracketed/
Moving commits between branches

Example: Moving up to a few commits to another branch

Branch A has commits (X,Y) that also need to be in Branch B. The cherry-pick operations should be done in the same chronological order that the commits appear in Branch A.

cherry-pick does support a range of commits, but if you have merge commits in that range, it gets really complicated

git checkout branch-B
git cherry-pick X
git cherry-pick Y

Raspberry Pi VPN Router

This is a quick-and-dirty guide to setting up a Raspberry Pi as a "router on a stick" to PrivateInternetAccess VPN.


Install Raspbian Jessie (2016-05-27-raspbian-jessie.img) to your Pi's sdcard.

Use the Raspberry Pi Configuration tool or sudo raspi-config to:

superjamie / 2014-10-31-running-a-python-script-only-if-it'
Last active Oct 11, 2015
2014-10-31 - Running a Python script only if it's not already running
View 2014-10-31-running-a-python-script-only-if-it'

I have a simple Linux graphical desktop environment, using the Openbox window manager and tint2 panel. I use gsimplecal to display a small GTK Calendar widget when I click the panel clock. When I click the clock again, the calendar disappears.

gsimplecal is written in C++ but I thought it might be fun to rewrite it in Python.

The hardest part was detecting the running process, so a script would find another instance of itself then kill that instance and exit, but run if there was no existing instance. I came up with this fairly universal solution:


from os import getpid
superjamie /
Last active Oct 11, 2015
2014-09-21 - The 8-Byte Two-Step Redux

Over on Hacker News, Z posted a fantastic article called The 8-Byte Two-Step where the concept of aligning to byte boundaries was explored.

I thought this was a fantastic post, it goes right down to binary and logical operators then back up again.

After understanding the alignment, Z then writes three other ways of doing the same thing, disassembles them and benchmarks them.

Discussing this on HN, I said:

I have banned myself from using printfs to figure out things like this. Instead I would use a debugger and breakpoints to view the live variables in their different data formats.

You can’t perform that action at this time.