Archive for May, 2009

ACM Banquet 2009

_MG_6835

Check out photos of the CSC Banquet 2009!

, ,

No Comments

ACM Banquet Center Pieces

_MG_6808

I had fun making these :P… roses and gold fish!

No Comments

Spring Dance Show – Unleashed

Unleshed - Spring  Dance Show

Check out photos of the 2009 Spring Dance Show!

, , ,

No Comments

Glow Printing

This seems useless in terms of practical application but its so cool!

, ,

No Comments

Lock Screen For Your Mac

For OS X.

In the dorms I used to have my mac lock itself as soon as it entered screensaver mode but now that I don’t have the constant mischievous pranks looming around the corner I don’t bother with that. So what I’m looking for is a way to lock my mac without having to ALWAYS enable it when in screensaver. The solution is in Keychain Access (Applications > Utilities). Launch the program and under Keychain Access:Preferences in the General tab, select “Show Status in Menu Bar”. Now a lock icon appears in your tray and the first option in the menu is “Lock Screen”. Sweet!

Note: you can move these icons around by holding down the apple key and dragging.

, , , , , ,

2 Comments

Restoring files or folders in SVN

To recover a folder or a file in svn, you can use the copy command to copy the folder from the revision of the repository before the file or folder was deleted (or modified). The syntax can be a bit confusing but here’s how it can be done. The first flag -r (i’m not sure if you need this the way this command is formatted) specified the revision you copy from. The next argument is the source and it needs to be the full path to the file or folder you’re recovering followed by @ and the revision number. then the location the to copy the data to (which can be just . for this folder).

Example:

svn cp -r 111 https://server/svn/path/to/folder@111 .
svn ci -m "restored file or folder"

, , ,

1 Comment

Building a 24″x36″ collapsable softbox for under $15!

_MG_6161

I’ve always wanted a softbox… and I found some tutorials online for a DIY softbox but as great as they were none of them were collapsible. I don’t have a lot of space so as much as I’d like softbox, I cant have a giant box taking up tons of space lying around. So I came up with this idea to make a collapsible one using rods (like you use to build a tent)… so the problem became finding the right material which would bend but stay straight when you released the tension. I eventually found these Reflector markers at Home Depot which were made from Fiberglass which were perfect. So I built this and bought some fabric… and bam… I have a softbox! I’ll eventually build myself a second one and I’ll take photos step-by-step and post some instructions… but this was just kind of my little experiment… so I didn’t document the steps because I honestly didn’t know what I was doing :P. But I have a materials list below, so If you want to try it… you shouldn’t have too much trouble figuring it out from my photos. And feel free to email me me@prenticew.com or leave a comment!

The rods I used:
Photo 8

Materials (from Home Depot)
(2) Break Resistant Fiberglass Reinforced Rods (From Reflective Markers) – $1.98 ea.
(2) 36″ rope/string/twine
(2) 3/4″ x 8″ square wood – $0.52 ea.
(2) 3/4″ x 3′ square wood (cut off 1′ for the rear frame) – $1.56 ea.
(4) 3/16″ x 2″ Eye Bolt with Nut – $0.98 for a bag of 2
(4) 2″ screws
(1) 3/8″ x 1″ hexbolt course thread (for attaching to lightstand 5/8″ male stud) – $0.18 ea.
(1) 1/4″ x 1″ hexbolt course thread (for attaching to 2nd lightstand 5/8″ male stud) – $0.11 ea.
(1) Simpson Strong Tie – $0.68 ea.
(1) 2 yrds x 44″ white fabric from Beverly’s @ $1.97/yrd
(1) 1 yrds x 44″ black fabric from Beverly’s @ $3.99/yrd

Some Photos
(I should’ve spent more time on these photos but I am far too busy for that… these are SOC processed in LR)

Testing out the softbox.

_MG_6157

Before I went out and bought fabric, I used some garbage bags temporarily.

_MG_6128

Construction:

The Eye Bolts to hold the rods

_MG_6154

The strong tie/bolt to attach the umbrella mount.

_MG_6153

The bolt to attach the box to the umbrella mount.

_MG_6156

The string to hold the top and bottom of the frame together.

_MG_6155

More photos of the completed softbox (though I haven’t had time to sew the fabric yet so they’re just clipped on… which is fine… because I’d question my own sewing skills 😛 ):

_MG_6161

_MG_6162

Test shots with the softbox:
_MG_6160

Softbox Only:

_MG_6164

Softbox + White card bounce:

_MG_6165

, , , , , ,

2 Comments

Rubber Ducky

This is a sweet video of a guy converting his bedroom into a studio and back. The way he shot the video was really cool, using a time lapse of still photos. Pretty amazing.

, , , , ,

No Comments

Named groups in Python regular expressions

Regular expressions are very powerful. Named groups in Python re make your re’s and code very readable and powerful. Here is a simple example but imagine how useful this would be for parsing a dataset such as a cvs list or datafile.

import re

def main():
   str=  "james:12;google."
   match = re.match(r"(?P<name>[^:]*):(?P<age>[^;]*);(?P<company>[^.]*)."
         ,str)
   print "name", match.group("name")
   print "age", match.group("age")
   print "company", match.group("company")

if __name__ == "__main__":
   main()

, ,

No Comments

Python Talk

I gave a talk on Python for cplug yesterday.  

Check out the slides here.

CPLUG: http://www.cplug.org/
SLIDES: http://prenticew.com/talks/pytalk09

During the talk, I wrote a simple Python script to pull content off the web and parse the data… here’s the jist of what I did:

First, lets pull a webpage off the internet:

import httplib
def get_webpage():
   conn = httplib.HTTPConnection('en.wikipedia.org')
   conn.request("GET","/wiki/Python_(programming_language)")
   rd = conn.getresponse()
   print rd.status, rd.reason
   return rd.read()

This function creates a HTTPConnection object for en.wikipedia.org and the connection object is stored in conn.
We then do a GET request for the Python wiki page. The result of the request is stored in the connection and we can access the status by calling getresponse() which returns a HTTPResponse object.
The status can be accessed with .status and .reason and the data can be accessed with .read().

This yields the plain-text html of the wiki page. This is not very interesting or useful so lets do something else with this data… lets write a frequency counter:

 def get_freqct(data):
     wordlist = data.split(' ')
     freqct = {}
     for s in wordlist:
       if s not in freqct:
         freqct[s]=1
       else:
          freqct[s]+=1
     return freqct 

We can pass the data (a string) we got from the first function to our get_freqct function. The function first uses the built-in string function to split the string by a white-space delimiter returning a list of words. We then iterate through the wordlist and generate the frequency count using the dictionary data type. At this point we have something fairly interesting but simply printing out this list is fairly cluttered… lets sort it!

You can quickly sort the contents of this dictionary with the sorted function:

import httplib
from operator import itemgetter

sol = sorted(d.items(), key=itemgetter(1))

This statement takes the items in d (the dictionary) and returns a list of tuples (key,data) and is sorted by the data field of the tuple using the itemgetter function. So you’ll end up with a sorted list of tuples ordered by the data field.

Then we can print the list with the following for loop:

   for word,count in sol:
      print word, ":", count

This for loop unpacks the contents of each of the tuples in the sorted list (sol) into the variables word and count. The variables are then printed with the print statement.

If you run this code… you’ll realize that a lot of HTML tags (or parts of HTML tags) get counted. This is not very desirable so lets filter them out using a regular expression!

data = re.sub(r'<[^>]+>','',data)

This regular expression takes the raw data (string) returned by the get_webpage function and replaces each occurrence of an HTML tag with an empty string.

Deconstructing the regular expression:
<- matches the ‘<‘ symbol
[^>]+ – matches one or more of anything except the ‘>’ symbol (where + means one or more)
>- matches the ‘>’ symbol

…and put it all together:

#!/usr/bin/python
import httplib
import httplibfrom operator import itemgetter
import re

def get_webpage(site,page):
   conn = httplib.HTTPConnection(site)
   conn.request("GET", page)
   rd = conn.getresponse()
   print rd.status, rd.reason
   return rd.read()

def get_freqct(list):
    freqct = {}
    for s in list:
      if s not in freqct:
        freqct[s]=1
      else:
         freqct[s]+=1
    return freqct

def main():
   data = get_webpage('en.wikipedia.org',"/wiki/Python_(programming_language)")
   data = re.sub(r'<[^>]+>','',data)
   d = get_freqct(data.split(' '))
   sol = sorted(d.items(), key=itemgetter(1))
   for word,count in sol:
      print word, ":", count

if __name__ == "__main__":
   main()

The following is a snippet of what the script would yield:

language : 24
code : 24
which : 24
by : 27
Retrieved : 32
with : 32
are : 33
as : 38
on : 50
for : 51
in : 64
is : 80
to : 92
a : 98
Python : 103
and : 122
of : 125
the : 144

, , , , , , , , ,

No Comments