Skip to content

Instantly share code, notes, and snippets.

View jeremyBanks's full-sized avatar

Jeremy Banks jeremyBanks

  • Canada
  • 06:32 (UTC -04:00)
View GitHub Profile
@jeremyBanks
jeremyBanks / template.py
Created August 5, 2008 08:43
[2010-01] "There's a string.Template? What's that do?"
#!/usr/bin/env python
from string import Template
t = 45
s = "test"
print Template("We have $t ${s}s.").substitute(locals())
@jeremyBanks
jeremyBanks / lrr.py
Created August 7, 2008 06:23
[2010-01] script to wait for new LRR postcast episode and download
#!/usr/bin/env python
# encoding: utf-8
import sys, os
import time
try:
import urllib2 as urllib # Python 2.5
except ImportError:
import urllib.request as urllib # Python 3.0
def main():
@jeremyBanks
jeremyBanks / Nice Numbers
Created August 8, 2008 10:11
[2010-01] "nice numbers", not sure what for
0 3
1 6
2 12
3 24
4 48
5 96
6 192
7 384
8 768
9 1536
@jeremyBanks
jeremyBanks / monitor.py
Created August 9, 2008 09:19
[2010-01] an lame sorta-functional network keyword monitor
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys, os
import subprocess
# This is a horrible little script written by someone who doesn't understand
# how to use tcpdumbp or subprocess well. It intends to display an allert
# whenever specified keywords (such as a password) are seen in network
# traffic. Along with the warning it sends 3 \x07 beeps to stdout, in case
@jeremyBanks
jeremyBanks / gist:4743
Created August 10, 2008 13:14
[2010-01] me updating ruby? i never knew i installed it back then. maybe i read why_ back then?
$ ruby --version
ruby 1.8.6 (2007-06-07 patchlevel 36) [universal-darwin9.0]
$ curl ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p71.tar.gz | tar xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4692k 100 4692k 0 0 47090 0 0:01:42 0:01:42 --:--:-- 32309
$ cd ruby-1.8.7-p71/
$ ./configure
[...]
creating config.h
@jeremyBanks
jeremyBanks / lifebyte.c
Created August 10, 2008 15:45
[2010-01] experimenting with 1d life, led to my old logo/avatar
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
#import <stdio.h>
#import <stdint.h>
#import <time.h>
// Setting two adjacent bits produce an oscillator of period six.
// Setting two bits seperated by another produce an oscillator of period four.
// Setting ever other bit produces a still life.
@jeremyBanks
jeremyBanks / gist:4818
Created August 11, 2008 06:45
[2010-01] me installing demjson way back, saved this for some reason
~ $ sudo easy_install demjson
Searching for demjson
Reading http://www.python.org/pypi/demjson/
Reading http://deron.meranda.us/python/demjson/
Reading http://www.python.org/pypi/demjson/1.3
Best match: demjson 1.3
Downloading http://deron.meranda.us/python/demjson/dist/demjson-1.3.tar.gz
Processing demjson-1.3.tar.gz
Running demjson-1.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-KDLyNu/demjson-1.3/egg-dist-tmp-eaLyKU
zip_safe flag not set; analyzing archive contents...
@jeremyBanks
jeremyBanks / avatar.py
Created August 11, 2008 07:16
[2010-01] I thought I saw the script that generated my avatar in a more recent post...
#!/usr/bin/env python
import Image
rows = (0x18, 0x24, 0x7E, 0x81, 0x42, 0xE7)
image = Image.new("RGB", (8, 8), (255, 255, 255))
pixels = image.load()
for y in range(len(rows)):
for x in range(8):
pixels[x, y + 1] = (0, 0, 0) if (rows[y] >> x) & 1 else (255, 255, 255)
@jeremyBanks
jeremyBanks / gist:5802
Created August 17, 2008 12:19
[2010-01] reminding myself how to check disk usage or something
du -k -d 1 | sort -n
@jeremyBanks
jeremyBanks / euler001.lisp
Created August 22, 2008 21:08
[2010-01] really noob sbcl, I guess
#!/usr/bin/env sbclx
; I'd like to do this with map/reduce stuff,
; but I'll not get ahead of myself yet.
(let
((sum 0))
(do
(
(i 1 (1+ i))
(limit 1000)
)