Skip to content

Instantly share code, notes, and snippets.

@th0ma5w
th0ma5w / easing.py
Created March 31, 2014 01:32
Easing Equations in Python (orig by Robert Penner)
# ported from http://www.gizma.com/easing/
# by http://th0ma5w.github.io
#
# untested :P
import math
linearTween = lambda t, b, c, d : c*t/d + b
@th0ma5w
th0ma5w / horoscopescrape.py
Created January 12, 2011 14:38
Example of Generating URLs for downloading
"""
Creates a list of URLs to stdout based on repeating patterns found in the site, suitable for use with WGET or CURL.
"""
import datetime
scopes=[
"aries",
"taurus",
@th0ma5w
th0ma5w / comparer.py
Created April 8, 2014 23:00
CSV logging script for stock dump1090
#!/usr/bin/python
#
# CSV logging script for stock dump1090
#
# Uses the Requests library to compare the state of planes in view
# and prints changes to standard out
#
# Start dump1090
# modify this script to point to your dump1090 URL if different
# run the script and pipe the output to a file eg:
@th0ma5w
th0ma5w / tzumi_server.py
Created June 10, 2018 23:54
Single Page Web Application and REST API for TzumiMagicTV
# th0ma5w at github
#
# requires:
# http://archive.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/zlib_1.2.7-1_ar71xx.ipk
# http://archive.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/python-mini_2.7.3-1_ar71xx.ipk
#
# python ./tzumi_server.py
#
import socket
# diff all
# Betaflight / OMNIBUS (OMNI) 4.0.2 May 5 2019 / 12:07:33 (56bdc8d26) MSP API: 1.41 / FEATURE CUT LEVEL 9
batch start
defaults nosave
mcu_id 001f001d5734570820363930
name QX65
feature -RX_PPM
feature -AIRMODE
feature RX_SERIAL
@th0ma5w
th0ma5w / addon.py
Created August 30, 2018 04:53
MSNBC Audio Kodi Plugin
import json, urllib2, sys, xbmcgui, xbmcplugin
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', 'CURL')]
tunein_json_url = "https://tunein.com/tuner/tune/?tuneType=Station&preventNextTune=true&waitForAds=false&audioPrerollEnabled=false&partnerId=qZjjnm85&stationId=297990"
tunein_data = json.loads(opener.open(tunein_json_url).read())
stream_url = tunein_data["DirectStreams"][0]["Url"]
addon_handle = int(sys.argv[1])
xbmcplugin.setContent(addon_handle, 'movies')
@th0ma5w
th0ma5w / multimon-ng-filter.py
Created January 25, 2014 20:21
A way that I got working of scripting the output of multimon-ng ... not sure why the pipes are weird, but things like tee or grep seem prevent multimon-ng from producing output.
import subprocess, sys
from datetime import datetime
from time import sleep
timestamp = lambda : datetime.now().isoformat()
# # pager_rtl.sh --
# rtl_fm -M fm -f 152.48M -r22050 -s88200 -g 42 -l 30
rtl_fm = subprocess.Popen("./pager_rtl.sh",
@th0ma5w
th0ma5w / test6.py
Last active December 3, 2017 21:36
A Larsen Effect pattern using MQTT, Differencing LED state, and Protobufs
import paho.mqtt.client as mqtt
import time
bot_reply = None
def update_reply(msg):
global bot_reply
bot_reply=msg.decode('utf-8')
topics = {
@th0ma5w
th0ma5w / xmas_lights.proto
Created December 3, 2017 21:25
A protobuf for describing LED strip control messages
syntax = "proto2";
message led {
required uint32 led = 1;
required uint32 red = 2;
required uint32 green = 3;
required uint32 blue = 4;
required uint32 intensity = 5;
}
@th0ma5w
th0ma5w / is_the_sun_up.py
Created December 3, 2017 21:15
Is the sun up in Columbus? Using PyEphem to figure it out
import ephem
def is_the_sun_up():
columbus = ephem.city('Columbus')
sun = ephem.Sun()
columbus.pressure = 0
sun.compute(columbus)
twilight = -6 * ephem.degree
return sun.alt > twilight