Skip to content

Instantly share code, notes, and snippets.


Andrew Dupont savetheclocktower

View GitHub Profile
savetheclocktower / init.js
Created Feb 28, 2022
Automatically close empty “Staged/Unchaged Changes” tabs in Atom
View init.js
// Close "Staged/Unstaged Changes" tabs when they become empty.
const EmptyMonitor = {
metaForElement: new Map(),
observerOptions: {
childList: false,
attributes: true,
subtree: false,
attributeFilter: ['class']
savetheclocktower / pretend-to-be-my-switch
Created Jun 18, 2018
pretend-to-be-my-switch: MAC address spoofing for OS X
View pretend-to-be-my-switch
#!/usr/bin/env ruby
# Spoofs your MAC address, but only while the script is running.
# Put your native MAC address at ~/.mac-native in "aa:bb:cc:dd:ee:ff" format.
# Put your Switch's MAC address at ~/.mac-switch in "aa:bb:cc:dd:ee:ff" format.
# Run this script with `sudo`. It will change your WiFi MAC address. Kill the
# script and it'll change the MAC address back just before exiting.
savetheclocktower / laundry-spy.ino
Last active Aug 12, 2018
Laundry Spy firmware
View laundry-spy.ino
// (see the blog post at
// ==============
// The baud rate of serial output for logging. If necessary, change the baud
// rate in your Serial Monitor to match this.
#define BAUD_RATE 115200
// The name by which this device will identify itself over mDNS (Bonjour).
View scrape_mdn.rb
#!/usr/bin/env ruby
# Scrape the JavaScript documentation on Mozilla Developer and store an index
# as a YAML file.
# The data is organized by "token." If someone hits ^H in the middle of the
# word "toUpperCase", we want to link them to the MDN page for
# `String.prototype.toUpperCase`. If they're in the middle of the word
# "indexOf", we want to let them choose between `Array.prototype.indexOf` and
# `String.prototype.indexOf`.
savetheclocktower / assign-categories
Last active Sep 6, 2017
Scripts for Nostalgia-Tron series, part 10
View assign-categories
#!/usr/bin/env ruby
require 'pathname'
require 'inifile'
require 'nokogiri'
rescue LoadError => e
puts "This script requires nokogiri and inifile:"
puts " $ gem install nokogiri inifile"
savetheclocktower / joystick-type
Last active Sep 20, 2021
ServoStiks & RetroPie
View joystick-type
#!/usr/bin/env ruby
require 'io/console'
require 'json'
require 'optparse'
require 'pathname'
$opts = do |opts|
opts.banner = "Usage: joystick-type [options] system game\nReturns the type of joystick for the given system and game."
opts.separator ""
View led-end
#!/usr/bin/env ruby
# For now, let's just turn all LEDs back on.
exec(%Q[/home/pi/bin/pacdrive -a -q])
savetheclocktower /
Last active Aug 14, 2022
Using a rotary encoder as a volume control for the Raspberry Pi

Using a rotary encoder as a volume control

On my RetroPie machine I wanted a hardware volume knob — the games I play use a handful of emulators, and there's no unified software interface for controlling the volume. The speakers I got for my cabinet are great, but don't have their own hardware volume knob. So with a bunch of googling and trial and error, I figured out what I need to pull this off: a rotary encoder and a daemon that listens for the signals it sends.

Rotary encoder

A rotary encoder is like the standard potentiometer (i.e., analog volume knob) we all know, except (a) you can keep turning it in either direction for as long as you want, and thus (b) it talks to the RPi differently than a potentiometer would.

I picked up this one from Adafruit, but there are plenty others available. This rotary encoder also lets you push the knob in and treats that like a button press, so I figured that would be useful for toggling mute on and off.

savetheclocktower /
Last active Jan 12, 2022
Poor-man's LEDBlinky with RetroPie and Pac-Drive

NOTE: This Gist was an early write-up of this blog post, part of what became an eleven-part series on my arcade cabinet. I'd suggest you read that post instead of this, but some of the comments on this Gist contain updates and field reports that you might find useful.

RetroPie, LED control, and you

I wanted LEDBlinky-style functionality out of my RetroPie cabinet. But I didn't need RGB control or magical frontend integration or anything like that. I had buttons with simple single-color LEDs.

I've got a simple control panel with six buttons per player. All I wanted was this:

  • When I launch Street Fighter 2, all twelve buttons should light up.
  • When I launch The Simpsons, only the first two buttons for each player should light up.
View Drag and drop styling
.dropzone {
background-color: #ccc;
width: 100%;
height: 200px;
border: 2px dashed #666;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: inset 2px 2px 10px 2px rgba(0, 0, 0, 0.5);