Skip to content

Instantly share code, notes, and snippets.

th0ma5w /
Created Dec 19, 2010
print the last x lines from your interpreter (default 50)
import readline
def readBack(length=50):
for line in this_readback:
print readline.get_history_item(line)
th0ma5w /
Created Jan 12, 2011
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
th0ma5w /
Created Jan 12, 2011
extract context from downloaded html files
Example of using the old BeautifulSoup API to extract content from downloaded html files into CSV... if you're doing this sort of thing today, I recommend using the newer lxml interface directly, but lxml also has a BeautifulSoup compatibility layer.
import os
th0ma5w /
Created Mar 1, 2011
play a sound when there's a tornado warning near me
# WARNING: If you want to use it, don't rely on it, and you'd have to edit it to get to work for you, wherever you are, if you're in the US.
from lxml import etree
from urllib2 import urlopen
from subprocess import Popen, PIPE
th0ma5w / directory.scm
Created May 22, 2011
Python-like dir function for scheme
View directory.scm
;Python-like dir function for Kawa scheme objects (but not the global namespace)
(require 'list-lib)
(require <kawa.lib.srfi95>)
;retrieve class name as string
(define classname (lambda (x) (invoke x 'getName)))
;make a one-dimensional array into a list
(define tolist (lambda (l) (map l (iota l:length))))
th0ma5w / gist:1297161
Created Oct 19, 2011
dim blue-green (traffic light mix) color filter for compiz
View gist:1297161
TEMP tex, temp;
TEX tex, fragment.texcoord[0], texture[0], RECT;
DP3 temp.r, tex, {0.01, 0.01, 0.01, 0};
DP3 temp.g, tex, {0.05, 0.05, 0.05, 0};
DP3 temp.b, tex, {0.04, 0.04, 0.04, 0};
MOV temp.a, tex.a;
MOV result.color, temp;
th0ma5w /
Created Apr 7, 2012
Play YouTube on LAN XBMC Eden
curl -d "{\"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \"params\":{\"item\": { \"file\" : \"plugin://$@\" }}, \"id\" : 1}" http://xbmc:xbmc@
# curl and everything after it should be on one line. change the port and host to your
# liking and your username and password if you've changed it from the default
th0ma5w / curve.clj
Created Nov 7, 2012
Bezier Curve Subdivision Functions
View curve.clj
(defn edges [listing]
(loop [accum (list (take 2 listing))
queue (rest listing)]
(if (> (count queue) 1)
(concat accum
(list (take 2 queue)))
(rest queue))
th0ma5w / gist:8327127
Created Jan 9, 2014
JSON parsing script for BitCoin prices within Google Docs
View gist:8327127
// Adds a menu option to refresh all options.
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Refresh",
functionName : "refreshLastUpdate"
sheet.addMenu("Refresh", entries);
th0ma5w /
Created Jan 25, 2014
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 :
# # --
# rtl_fm -M fm -f 152.48M -r22050 -s88200 -g 42 -l 30
rtl_fm = subprocess.Popen("./",