This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bash snippet to open new shells in most recently visited dir. | |
# Useful if you want to open a new terminal tab at the present | |
# tab's location. | |
# | |
# Put this in your .bashrc or whatever. | |
pathed_cd () { | |
if [ "$1" == "" ]; then | |
cd | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# brainf*** Interpreter in Python | |
# Copyright (c) 2002 & 2006, James Tauber | |
# | |
# see http://en.wikipedia.org/wiki/Brainfuck | |
import sys | |
class brainf: | |
def __init__(self, program): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python implementation of the Gibbons-Lester-Bird algorithm[1] for enumerating | |
# the positive rationals. | |
# | |
# James Tauber 2004-07-01 | |
# http://jtauber.com/ | |
# | |
# [1] http://web.comlab.ox.ac.uk/oucl/work/jeremy.gibbons/publications/rationals.pdf | |
def rationals(): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation of Simon Plouffe's formula for Pi in Hex | |
# | |
# James Tauber 2007-03-14 | |
# http://jtauber.com/blog/2007/03/14/generating_the_hex_digits_of_pi/ | |
def pi(): | |
N = 0 | |
n, d = 0, 1 | |
while True: | |
xn = (120*N**2 + 151*N + 47) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |
OlderNewer