Skip to content

Instantly share code, notes, and snippets.

@th0ma5w
th0ma5w / tiles.clj
Created Mar 27, 2014
Tile Server Quad Tree Math
View tiles.clj
(import 'java.lang.Math)
(defn tile-count [z]
(Math/pow 2 z))
(defn deg2num [lat_deg lon_deg z]
(let [lat_rad (Math/toRadians lat_deg)
n (tile-count z)
x (int (* (/ (+ lon_deg 180.0) 360.0) n))
y (int
@th0ma5w
th0ma5w / easing.py
Created Mar 31, 2014
Easing Equations in Python (orig by Robert Penner)
View easing.py
# 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 / comparer.py
Created Apr 8, 2014
CSV logging script for stock dump1090
View comparer.py
#!/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:
View core.clj
(ns quiltest.core
(:require
[quil.core :as q]
[quil.applet :as qa]
)
(:import
[javax.swing JFrame])
)
@th0ma5w
th0ma5w / is_the_sun_up.py
Created Dec 3, 2017
Is the sun up in Columbus? Using PyEphem to figure it out
View is_the_sun_up.py
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
@th0ma5w
th0ma5w / xmas_lights.proto
Created Dec 3, 2017
A protobuf for describing LED strip control messages
View xmas_lights.proto
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 / test6.py
Last active Dec 3, 2017
A Larsen Effect pattern using MQTT, Differencing LED state, and Protobufs
View test6.py
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 / tzumi_server.py
Created Jun 10, 2018
Single Page Web Application and REST API for TzumiMagicTV
View tzumi_server.py
# 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
@th0ma5w
th0ma5w / addon.py
Created Aug 30, 2018
MSNBC Audio Kodi Plugin
View addon.py
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')
View BTFL_cli_QX65_20190516_180526.txt
# 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