Skip to content

Instantly share code, notes, and snippets.

@klattimer
klattimer / shazamtags.py
Created December 19, 2023 11:07
Fix your MP3 id3 metadata using Shazam (songrec)
#!/usr/bin/env python3
#
# Script assumes you have songrec and id3tool installed.
#
# https://github.com/marin-m/SongRec
# https://github.com/zerodivide1/id3tool
#
# Once you've got those installed, just run it from the current path, installing to /usr/local/bin or whatever you like
# It'll find all mp3 files, use songrec to recognise them, and id3tool to fix the tags, optionally you may want to use
# id3ren to rename the files appropriately.
@klattimer
klattimer / esp01s-fastled-mqtt.ino
Created December 14, 2020 15:59
ESP01S FASTLED over MQTT
/* ESP01S lighting controllers are pretty cheap, you can get them on aliexpress/ebay/amazon etc...
* https://www.amazon.co.uk/ESP8266-ESP-01-ESP-01S-Controller-Electronic/dp/B0819VRPXX
*
* A bit thin on decent software though, so I've cobbled together this MQTT client that lets you
* use MQTT to change the LED colours. With LED0 reserved for status of the device itself.
*/
#include "EspMQTTClient.h"
#include <FastLED.h>
#!/bin/bash
#
# GIT to MQTT Publishing hook
#
# This script provides a post-update hook solution which is intended to be self-contained and simply publish to
# a mosquitto server the current most recent commit ref for each branch.
#
# Once the branch is published clients subscribed to that specific topic will be informed of their necessity to
# update.
#
@klattimer
klattimer / gist:151d9cf133d595db7d7517ac07d9f671
Created May 17, 2019 21:28
Arduino Single Joystick Car control
// Single analogue joystick control for dual motors
//
// Applications include
// - Accessible control for single handed people
// - free up the second analogue stick for adding weapons or camera control
// - improving on the arduino battle bot PS2 code
// PS2X lib is buggy, especially with my cheapo controllers which have a few bits flipping
// randomly, other than that, and a little bit of a pain with a poor connection, it seems
// to work reliably enough most of the time. YMMV
@klattimer
klattimer / emukill
Created February 26, 2018 09:09
Kill emulator
#!/bin/bash
# Kills whatever emulator was started with emurun
# Sets up audio volume and re-enables suspend.
DISPLAY=:0.0
if [ -f ~/emu.pid ]; then
PID=`cat ~/emu.pid`
if ps -p $PID > /dev/null; then
echo -n "Sending sigint to $PID..."
kill -SIGINT $PID
fi
@klattimer
klattimer / emurun
Last active February 26, 2018 09:10
Run emulator with easy hacks
#!/bin/bash
# Execute an emulator which is linked to this script, e.g. ln -s ~/bin/emurun ~/bin/dolphin-emu-nogui
# Then execute ~/bin/dolphin-emu-nogui to wrap it in this, disables suspend timers sets the TV volume and moves the cursor
# out of the way. Importantly it kills pulseaudio which does horrible things to audio.
#
export DISPLAY=:0.0
export PATH=/usr/games:$PATH
EX=`basename $0`
echo autospawn = no > $HOME/.config/pulse/client.conf
/bin/kill -9 `/bin/pidof pulseaudio`
@klattimer
klattimer / kodi-shutdown-control.py
Created December 17, 2017 19:28
Enable/Disable kodi powersaving via python
# requires: https://github.com/jcsaaddupuy/python-xbmc
#
# enable/disable kodi power management shutdown timer
#
# weird bug when you enable after 5 minutes of it sitting idle, it will shutdown... almost as if the timer is always going
#
from xbmcjson import XBMC
import sys
if __name__ == "__main__":
@klattimer
klattimer / openwrt-status.py
Created March 22, 2016 18:55
I wrote this because I wanted to get the JSON data from OpenWRT's status page and use it elsewhere. Fill out the user name and password, sorry it's a bit hacky but I'm rolling it into other stuff and this is a minimum implementation.
import requests
import re
import urllib2
url = 'http://openwrt/cgi-bin/luci/'
data = {'luci_username': 'root', 'luci_password': 'password'}
r = requests.post(url, data=data, allow_redirects=True)
cookie = r.request.headers['Cookie']
m = re.search('sysauth=(.*)', cookie, re.IGNORECASE)
sysauth = m.group(1)