Skip to content

Instantly share code, notes, and snippets.

View timtadh's full-sized avatar
🔥
it's a trap!

Tim Henderson timtadh

🔥
it's a trap!
View GitHub Profile
@timtadh
timtadh / clear_line.py
Created January 12, 2011 16:38
python repl howto
left = chr(27)+chr(91)+chr(68)
right = chr(27)+chr(91)+chr(67)
backspace = left + ' ' + left
def clear_line(prompt, l):
for x in xrange(150 - l):
sys.stdout.write(right)
for x in xrange(150):
sys.stdout.write(backspace)
sys.stdout.write(prompt)
sys.stdout.flush()
@timtadh
timtadh / gist:1169064
Created August 24, 2011 20:09 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
Day job:
PhD. Student @ Case Western Reserve in Software Engineering (Program Analysis)
Favorite Python project:
PLY (Python Lex and Yacc)
Favorite Conference:
PyOhio
Python Experience Level:
@timtadh
timtadh / screen.css
Created October 10, 2011 03:21 — forked from jasonm23/screen.css
markdown friendly css
html { font-size: 62.5%; }
html, body { height: 100%; }
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 150%;
line-height: 1.3;
color: #f6e6cc;
width: 700px;
margin: auto;
@timtadh
timtadh / newegg.py
Created November 7, 2011 12:10
How to extract all of the items (name, price) from Newegg.
import itertools
import requests, lxml, lxml.html
import json
# 7603 Hard Drives
# 7611 RAM
# 6642 random store
def newegg_stores_req():
r = requests.api.get('http://www.ows.newegg.com/Stores.egg/Menus')
return [store['StoreID'] for store in json.loads(r.content)]
@timtadh
timtadh / stevepipes.rst
Created December 1, 2011 20:10 — forked from irskep/newpipes.rst
Pipes3k

Commands defined and referenced by [ID]: "command in quotes"

After definition, commands may be referenced by ID

Connections defined by reference => reference [=> reference ...]

Expressions are separated by ;

  • file1.txt: one
  • file2.txt: two
@timtadh
timtadh / .gitignore
Created August 15, 2012 21:36
Validate Json
*.pyc
*.swp
env
#!/usr/bin/env python
import sys
import random
from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from hbase import Hbase
from hbase.ttypes import *
from datetime import datetime
# backup-trello
description "regular background program processing daemon"
start on (local-filesystems and net-device-up IFACE!=lo)
setuid hendersont
setgid hendersont
env HOME=/home/hendersont
export HOME
@timtadh
timtadh / upsert.py
Created December 5, 2013 19:14
How to compile an INSERT ... ON DUPLICATE KEY UPDATE with SQL Alchemy with support for a bulk insert.
#!/usr/bin/env python
# Copyright (c) 2012, Tim Henderson
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# - Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
package cwru.kxh337.arrowc.il;
import java.util.Map;
import java.util.LinkedHashMap;
import com.google.gson.Gson;
public class IntValue extends Value {
int value = 0;