Skip to content

Instantly share code, notes, and snippets.

@mbafford
mbafford / litter_monitor
Created March 20, 2015 19:37
Arduino Nano w// Ethernet Support - Litter Box Monitor
#include <EtherCard.h>
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
int PIN_DETECTED = 6;
int PIN_CYCLING = 5;
int PIN_WAITING = 4;
int PIN_LED = 13;
void flash(int n, int d) {
@mbafford
mbafford / gist:d32c67fe8b8f56159e99
Created March 18, 2015 01:31
Google Location History to Heatmap
Download location history on takeout
https://www.google.com/settings/takeout
Extract and get json file
Convert json file to coordinates
python -c 'import sys, json; e7=10000000.0; locs = json.load(sys.stdin)["locations"]; print("\n".join( "%s %s" % ( loc["latitudeE7"]/e7, loc["longitudeE7"]/e7 ) for loc in locs ))' < LocationHistory.json > locations.lst
@mbafford
mbafford / SONOS Pandora Ad Auto-Mute
Created March 11, 2015 14:17
You can't skip Pandora ads on Sonos (not even with UPNP commands), but you can mute them. This just watches for a Pandora ad playing and mutes the audio until the ad has finished. A much better approach is to just pay for Pandora.
#!/usr/bin/env python
import soco
import time
import re
# pandora song:
# {u'album': 'Everything All The Time', u'artist': 'Band Of Horses', u'title': 'The Funeral', u'uri': 'pndrradio-http://audio-ch1-t1-2-v4v6.pandora.com/access/?version=4&lid=3729520&token=slyAWqqgjJ8Bl3TgMB%2F03C4tamOHsLj%2BOQLq1T8xbiwSzkcoc253HeYbNFTcOP7K6Oy9GOq6tcaManOhyKDpECIiCENj7hjBsH%2FJVhJnDjLzyPRWjg8q0LtX1mn80yFiurvB1r0G0Be76YBZJUswLdWtNZtfYSO2y2WdYHSge8Ul2hML1MWvkv23AQjw9%2BAKPmIHXX8nUzfcfFfLfmyKk%2Flxwh2cf%2BvDrJIbnnVZfvlfirWhshENZDm7BBofIlUqR0qsPXWbYN5m7WD4bS3XCK4dedE0QtHIlBaGvNIwNrorp3j5EoZM%2BybBEigsDXg%2B9To1w30%2BRbV8V3o6hyM5lpviYM4icmRBYVVjmA4hlWOE7aOFqcNAPA%3D%3D&a=http%3a%2f%2fcont-sv5-3.pandora.com%2fimages%2fpublic%2famz%2f0%2f2%2f0%2f9%2f098787069020_500W_500H.jpg&m=94f084d4cda66036692600d16036898d258a387c7a546916b33f7d907698ddf0e59d86721b571e2bfd793b4d25efc3cc856420f223031811&f=1&r=0&g=-5.93&x=000020aa', u'playlist_position': '4', u'duration': '0:05:22', u'position': '0:03:09', u'album_art': 'http://cont-sv5-3.pando
@mbafford
mbafford / .gitignore
Last active February 4, 2020 14:17
Quick and simple program to convert the Diecast podcast (http://www.shamusyoung.com/twentysidedtale/?cat=287) RSS feed into something my podcast reader can handle. It simply pulls the mp3 URL from the description and adds an enclosure element pointing at that URL.
diecast.xml
run.sh
original-rss.xml
.env/