Skip to content

Instantly share code, notes, and snippets.

View savetheclocktower's full-sized avatar

Andrew Dupont savetheclocktower

View GitHub Profile
@savetheclocktower
savetheclocktower / pulsar-ide.md
Last active December 25, 2023 21:58
IDE packages for pulsar

Pulsar IDE

Pulsar doesn’t have a cohesive IDE experience out of the box, but various packages can collaborate to provide it:

  • On the backend, any package that uses atom-languageclient, or any language server configured for use with generic-lsp, can provide any of the services listed below.
  • On the frontend, any package that consumes the services listed below can give the user a UI for the given feature.

The services

In general, a backend provides a service and a frontend consumes it. Here are the major services that are provided by atom-languageclient and similar sources, along with the packages in PPM that can consume them:

@savetheclocktower
savetheclocktower / index.js
Created December 14, 2022 21:32
Preact scanner frontend
import { h } from 'preact';
import { useEffect, useState } from 'preact/hooks';
import style from './style.css';
let socket;
const HOSTNAME = `paperless.local:8081`;
const Progress = () => {
return (
@savetheclocktower
savetheclocktower / init.js
Created February 28, 2022 18:00
Automatically close empty “Staged/Unchaged Changes” tabs in Atom
// Close "Staged/Unstaged Changes" tabs when they become empty.
const EmptyMonitor = {
metaForElement: new Map(),
observerOptions: {
childList: false,
attributes: true,
subtree: false,
attributeFilter: ['class']
},
@savetheclocktower
savetheclocktower / pretend-to-be-my-switch
Created June 18, 2018 19:35
pretend-to-be-my-switch: MAC address spoofing for OS X
#!/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
savetheclocktower / laundry-spy.ino
Last active August 12, 2018 21:38
Laundry Spy firmware
// (see the blog post at https://andrewdupont.net/2018/04/27/laundry-spy-part-3-the-software/)
// GENERAL CONFIG
// ==============
// 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).
#!/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
savetheclocktower / assign-categories
Last active September 6, 2017 03:25
Scripts for Nostalgia-Tron series, part 10
#!/usr/bin/env ruby
require 'pathname'
begin
require 'inifile'
require 'nokogiri'
rescue LoadError => e
puts "This script requires nokogiri and inifile:"
puts " $ gem install nokogiri inifile"
@savetheclocktower
savetheclocktower / joystick-type
Last active March 5, 2024 18:52
ServoStiks & RetroPie
#!/usr/bin/env ruby
require 'io/console'
require 'json'
require 'optparse'
require 'pathname'
$opts = OptionParser.new do |opts|
opts.banner = "Usage: joystick-type [options] system game\nReturns the type of joystick for the given system and game."
opts.separator ""
#!/usr/bin/env ruby
# For now, let's just turn all LEDs back on.
exec(%Q[/home/pi/bin/pacdrive -a -q])
@savetheclocktower
savetheclocktower / README.md
Last active October 6, 2024 20:19
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.