|
October 23rd, 2009
12:58 pm - PDF Concatenation
pdftk *.pdf cat output /tmp/foo.pdf
Looks like it can do a bunch of other useful stuff too.
|
February 26th, 2009
10:21 pm 1 pt apricot nectar + 1 pt sparkling mineral water + .5 pt awesome FTW!
|
May 16th, 2008
December 19th, 2007
11:41 pm
avani made me upload some user pics.
|
March 25th, 2007
10:04 am

Your friends and associates should generally find you a dependable and trustworthy person. You are a direct and forthright person. You like to get to the core of the issue right away, with few signs of hesitation. You like following the rules and being objective. You are precise and meticulous, and like to evaluate decisions before making them. You have a sunny, cheerful disposition.
What does your drawing say about YOU?
|
September 25th, 2006
08:50 pm - Cat!
Safe and sound and grungy!
|
April 25th, 2006
07:55 pm Want to have fun while picking up heavy stuff, solving discrete knapsack and bin-packing problems, then putting it down? Are you in Silicon Valley? Nothing to do Friday night?
Then you want to come to my Moving Party. Yay!
- When: Friday, April 28th. 7pm onwards
- Where: My Place, Mountain View, to My New Place, Sunnyvale (about 6 miles)
- Bring: muscles, friends, handy moving equipment (although I don't expect to need it, 'cause I can lift nearly everything myself...)
- I'll supply: Mostly packed stuff, drinks, pizza, limited vehicular space, etc.
The plan:
- Move stuff
- Repeat step 1 until done, or bored
- Hang out in Sunnyvale.
(Because it worked so well for patrissimo and choiceful...)
|
March 4th, 2006
01:26 am - Mucking with big datafiles in python This version isn't exactly optimized...
import array
import struct
BLOCKSIZE=8192
def csviter(file, type):
"""
Pseudo-parses a csv file with a single record and iterates over the
columns.
"""
return sepiter(file, ',', type)
# Turn a 4 byte binary string into a float
def unpackfloat(binstring):
x = struct.unpack('f', binstring)
return x[0]
def sepiter(file, sep, type,
skip=str.isspace, blocksize=None):
"""
Iterate over elements in file seperated by sep.
Args:
file: file-like object that supports .read(size)
sep: single character seperator.
type: function to call to create each item from a string
skip: Filter function. If true, skips the given item.
Applied to string value before type.
Defaults to str.isspace.
blocksize: how many bytes to read at once.
Defaults to value of the global BLOCKSIZE at construction time.
"""
assert len(sep) == 1, "sep must be a single character"
if blocksize is None: blocksize = BLOCKSIZE
buffer = array.array('c')
end = None # the end of the data for the current item
# Loop over every item in the input
while True:
# Fill buffer until EOF or it includes sep.
# Return if out of buffer and out of input
while True:
try:
end = buffer.index(sep)
break
except ValueError:
data = file.read(blocksize)
if not data and not buffer:
# Out of buffered data and file data. All done.
return
if not data:
# EOF. Continue processing buffered data.
end = len(buffer)
break
data.rstrip("\r\n")
buffer.fromstring(data) # O(N) / O(N^2) faster than .extend
# The buffer has some data in it. Pull and yield a single value.
item = buffer[:end].tostring()
# Erase item + sep. If array.index had a start argument, we could
# avoid shifting the entire array here.
buffer[:end + 1] = array.array('c')
if not skip(item):
yield type(item)
def biniter(file, recordsize, type, recordblocksize=None):
"""
Iterate over fixed size records in a file.
Args:
file: File-like object that supports .read(size)
recordsize: Number of bytes in a single record.
type: Type constructor for each item.
recordblocksize: Number of records to read from the input at a time.
Defaults to the number of records that can fit in BLOCKSIZE rounded
up to the next whole record.
"""
if recordblocksize is None:
recordblocksize = int((BLOCKSIZE / float(recordsize))+.5)
buffer = array.array('c')
buffer_pos = 0
blocksize = recordsize * recordblocksize
while True:
while len(buffer) - buffer_pos < recordsize:
data = file.read(blocksize)
if not data and buffer_pos >= len(buffer):
return
if buffer_pos == len(buffer):
buffer_pos = 0
buffer = array.array('c')
elif len(buffer) > blocksize:
buffer[:buffer_pos] = array.array('c')
buffer_pos = 0
if not data:
break
buffer.fromstring(data)
yield type(buffer[buffer_pos:buffer_pos+recordsize].tostring())
buffer_pos += recordsize
|
February 26th, 2005
09:52 pm If you're a computery person, it's likely that my dad's blog will be of interest: http://wilsond.blogspot.com/
|
February 13th, 2005
08:27 pm - Ties that bind Avani found a paper that describes tie tying in a way that's actually understandable. Yay!
|
October 24th, 2004
08:39 pm - Corporaticide Well, DRA is dead, Paracel is almost dead... I guess its time to set my sights on Google.
|
May 1st, 2004
02:02 pm Look! A snakebite!
 Of course, now I have to apologize to all of the people to whom I've claimed that Hiro can't break skin.
|
|
|
|