Skip to content

Instantly share code, notes, and snippets.

View jtauber's full-sized avatar

James Tauber jtauber

View GitHub Profile
#!/usr/bin/env python
import os
import os.path
for root, dirs, files in os.walk("."):
for filename in files:
path = os.path.join(root, filename)
if any(filename.endswith(ending) for ending in [".py", ".html", ".txt", ".css"]):
tabs = False
#!/usr/bin/env python
import os
import os.path
for root, dirs, files in os.walk("."):
for filename in files:
path = os.path.join(root, filename)
if any(filename.endswith(ending) for ending in [".py", ".html", ".txt", ".css"]):
marked = []
@jtauber
jtauber / AKALABETH
Last active September 18, 2015 04:45
Akalabeth Files, detokenized from disk images in Asimov Apple ][ Archive using https://github.com/jtauber/a2disk
0 ONERR GOTO 4
1 REM
4 PR # 0: IN # 0
5 HIMEM: 49151
7 CLEAR : GOSUB 60000
8 ZZ = RND ( - ABS (LN))
9 LEVEL = 0
10 TEXT : HOME : NORMAL : VTAB (12): PRINT " WELCOME TO AKALABETH, WORLD OF DOOM!"
20 DIM DN%(10,10),TE%(20,20),XX%(10),YY%(10),PER%(10,3),LD%(10,5),CD%(10,3),FT%(10,5),LAD%(10,3)
30 FOR X = 0 TO 20:TE%(X,0) = 1:TE%(0,X) = 1:TE%(X,20) = 1:TE%(20,X) = 1: NEXT
@jtauber
jtauber / .bash_profile
Created September 3, 2011 10:55
OS X 10.7 Setup
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
RED="\[\033[01;31m\]"
GREEN="\[\033[32m\]"
LGREEN="\[\033[01;32m\]"
YELLOW="\[\033[01;33m\]"
BLUE="\[\033[01;34m\]"
PURPLE="\[\033[01;35m\]"
CYAN="\[\033[01;36m\]"
How I created a Google Apps jtauber@jtauber.com gmail account when I already had a Google Account called
jtauber@jtauber.com:
1) While signed in to jtauber@jtauber.com Google Account, I created a temporary @gmail.com email address.
This effectively enabled me to alternatively log into my existing Google Account via that @gmail.com address
2) I logged out and signed up for Google Apps with username admin@jtauber.com
3) I added a 'jtauber' user under the jtauber.com Google Apps domain and gave it Super Admin privileges.
That effectively shut out my ability to log into my original Google Account with jtauber@jtauber.com but
I still can using the temporary @gmail.com address created in step 1.
import colorsys
VALUE = 0.8
def to_hex(h, s, v):
return "#%02X%02X%02X" % tuple(int(255 * i) for i in colorsys.hsv_to_rgb(h, s, v))
def generate_colour():
a = 1
while True:
@jtauber
jtauber / trim_zip.py
Created February 27, 2012 20:48
trim extra data off end of zipfile
import struct
ECD_SIG = "\x50\x4B\x05\x06"
ECD_LEN = 22
def trim_zip(filename_in, filename_out):
"""
trims the zipfile give by filename `filename_in`, removing any bytes
after the end of central directory record and writing the result to
a file with filename `filename_out`.
def bitstruct(structure, value):
result = []
index = 8
for part in structure:
result.append((value & ((2 ** index - 1) - (2 ** (index - part) - 1))) >> (index - part))
index -= part
return tuple(result)
if __name__ == "__main__":
assert bitstruct((8, ), 42) == (42, )
@jtauber
jtauber / gist:3140197
Created July 19, 2012 01:37
Blogging, Twitter and something in between
I don't want to get too deep into the psychology of why I stopped blogging other than to suggest that when you don't blog for a while, it raises the bar of what you break your blogging drought with. There was one time I didn't blog for a couple of months and the next time I blogged, a friend said "I've waited months for a blog post and you post THAT!".
So to get back to putting more content on my site, I need to give myself permission to do shorter, less well-thought-out posts and not feel that every post has to be an epic article. Looking at the taxonomy above, it's clear that in the past I have made blog posts considerably shorter than informational articles.
I think there is value in distinguishing short-form and long-term posts and making enough of a separation that there is less pressure to always do long-term posts. But as well as the dimension of length, I think it also makes a lot of sense to distinguish posts which are ephemeral (or at least quite specific to the time in which they were made) from
#!/usr/bin/env python3
import sys
lines = []
parent_by_id = {}
rel_by_id = {}
with open(sys.argv[1]) as f:
for line in f: