Showing posts with label random. Show all posts
Showing posts with label random. Show all posts

Friday, August 28, 2009

It's Been a While

Indeed it has. So much has happened within the past month or so. Mom and Lowell came to visit. Benedikt our German intern moved in downstairs. My son Ben has grown a lot, holding his head up, smiling, etc. We even took him to Sears for a photo session. He was such a ham. I'll get some of the photos up sometime. I got offered a cool opportunity at work to present a scientific paper in November. Becky, Ben and I went to Anchorage for her cousins wedding. We shopped a lot, I had Arby's =), and we met up with a friend of hers. Yeah a lot has been going on.

I've been spending most of my time working on the science project. I was told I'm the only person at the facility that could possibly pull it off so naturally I accepted. The appeal to my ego worked it seems and now i'm spending many late nights in the office cranking out code and building a number crunching machine. That, actually, has been a real pain in the but. It's an 8-core xeon rig, with 12GB ram, and about 10TB storage. I've been having networking issues that after about 5 full days and extremely late nights of troubleshooting ended up being that it was plugged into a network switch that was failing. Good going linksys. Your $20 switch cost us about $1000+ in man-hours. Stupid.

Over the past month I've been coding a lot in python. It rocks my face off so hard I can't begin to describe. Part of my project involved doing a baseline set of image processing. I had the majority of the code completed in about two days because python handled a lot of the tedious stupid stuff like file management, memory management, and options parsing. I spent the next few days learning about the multiprocessing library so i could fork the number crunching software to multiple cpus. I only had 70 images to process for this round, but it took a whole 13 hours because i only had 2 cpus on my desktop. With my new server I can fork them to 8 cpus running about the same speed. Essentially it will be a switch from having a cpu limited process, to a throughput limited process. Each image is about 1GB, and I can only push data around from the hdd's so fast.

Anyways I should get going for now.

Laters

Friday, July 10, 2009

Python - Recursively Zip Directories (extended)

This looks pretty useful, especially for work since we rip through hundreds of files for zipping and unzipping.

The idea and snippet are from Corey Goldberg's post sharing the work he did to improve a bit of recursive zipping code. I extended what he made to include command line options and some usage help, complete with lazy loading in case somebody wants to use it as a library later. Just wanted to share and record for my own purposes.


#!/usr/bin/env python

import os, zipfile

def zipper(dir, zip_file):
zip = zipfile.ZipFile(zip_file, 'w', compression=zipfile.ZIP_DEFLATED)
root_len = len(os.path.abspath(dir))
for root, dirs, files in os.walk(dir):
archive_root = os.path.abspath(root)[root_len:]
for f in files:
fullpath = os.path.join(root, f)
archive_name = os.path.join(archive_root, f)
print f
zip.write(fullpath, archive_name, zipfile.ZIP_DEFLATED)
zip.close()
return zip_file

if '__main__' == __name__:
# Late import, in case this project becomes a library, never to be run as main again
import optparse

# Populate our options, -h/--help is already there for you
usage = "usage: %prog [options]"
version="%prog 1.0"
parser = optparse.OptionParser(usage=usage, version=version)
parser.add_option("-d", "--dir", dest="inputDir", default="~/test", action="store", help="sets the input directory to something other than the default (~/test)")
parser.add_option("-f", "--file", dest="outputFile", default="~/temp/test.zip", action="store", help="sets the output zip file to something other than the default (~/temp/test.zip)")
parser.set_defaults()

# Parse the arguments (defaults to parsing sys.argv)
(options, args) = parser.parse_args()

# Here would be a good place to check what came in on the command line and
# call parser.error("Useful message") to exit if all is not well
if len(args) > 0 and (1 != options.inputDir or 1 != options.outputFile):
parser.error("Additional arguments are not supported\nYou can only change the inputDir or outputFile using the -d and -f options.\nType zippy.py -h for help.\n")


# Do the actual work
zipper(options.inputDir, options.outputFile)

Thursday, July 9, 2009

Weekend

My Arduino has arrived and I'm stoked =P Now I need to make some time to mess around with it. There are some oscilloscope projects I'm interested in fiddling with. Link Link Link

This morning I found a nifty little snippet for adding an ascii spinner to your output. So if you have a long process, which we face often here at work, you can have this displaying to let you know it's doing stuff.

And of course this Saturday is when Mom, Lowell, and my Grandparents are arriving for a week long visit =D To say we're excited is an understatement. So much to do in just a week.

Ben is looking into some local positioning systems. I don't know much about these yet so some investigation is needed. Surely there's a way to use bluetooth or rfid in a manner similar to how gps works.

Tuesday, June 30, 2009

On Productivity

One of my biggest problems is distraction and forgetfulness. There are so many projects and related things I want to get to that finding time to do them, heck even remembering to do them, is becoming a real challenge. Thats why when I come across good ideas for addressing this, I try to remember them.

Here is a nice collection from lifehacker for productivity

Try some of those out and let me know what you think.

Oh, and Firefox 3.5 was released =) We finally have multi-threaded Firefox =P

Now my system shouldn't hang so bad when I have 100 tabs open. Woot