Archive for August, 2009

My apartment and my “garlic bread” 3

Theoretically, I was supposed to have moved into my apartment last weekend. However, having come just the week before, I didn’t much feel like packing my stuff up again only to make another move, even if it was just across town. In total, this week has consisted of 4 or 5 trips to campus to move my stuff slowly into my apartment. Now, however, everything is here, including me! After a grueling two hours of hacking at my desk (which I found in my house’s basement), and another two of cleaning up and unpacking stuff, I finally have a decent setup. Illustrated in pictures, of course:

My Bed:
Bed

My end table:
Clock + Phone

Read more »

YayMorse v.01, a morse code library for Arduino 0

I’ve been playing with my Arduino, and wrote up a small library for morse code. Right now it only serves up characters A-Z and a-z, but whatever. I’ll work on writing up some documentation for it at some point too.

Here’s a small script detailing how I interacted it with it to display tweets with morse code. It’s a little hacked script from an honors project, so it will be ugly, of course:

import mechanize
from urllib2 import HTTPError
from BeautifulSoup import BeautifulSoup
import string
import serial

def get_user_tweets(userid):
	tweets = []
	try:
		page = 1
		while True:
			request_user = mechanize.Request("http://twitter.com/" + userid + "?page=" + str(page))
			response_user = mechanize.urlopen(request_user)
			body_user = response_user.read()
			soup_user = BeautifulSoup(''.join(body_user))
			attrs = {}
			attrs['class'] = "entry-content"
			tagName = 'span'
			extract_tweets = soup_user.findAll(tagName,attrs)

			for e in extract_tweets:
				tweet = e.findAll(text = True)
				tweet = "".join(tweet)
				tweets.append(tweet)

			attrs = {}
			attrs['id'] = "pagination"
			tagName = 'div'
			more_tweets = soup_user.findAll(tagName,attrs)
			if len(more_tweets) == 1:
				break
			page+=1
		return tweets

	except HTTPError:
		print "Error fetching user data"

def get_latest_tweet(userid):
	tweets = []
	try:
		page = 1
		request_user = mechanize.Request("http://twitter.com/" + userid +"?page=" + str(page))
		response_user = mechanize.urlopen(request_user)
		body_user = response_user.read()
		soup_user = BeautifulSoup(''.join(body_user))
		attrs = {}
		attrs['class'] = "entry-content"
		tagName = 'span'
		extract_tweets = soup_user.findAll(tagName,attrs)
		for e in extract_tweets:
			tweet = e.findAll(text = True)
			tweet = "".join(tweet)
			tweets.append(tweet)
		print tweets[0]
		return tweets[0]
	except HTTPError:
		print "Error fetching user data"

if __name__ == "__main__":
	ser = ''
	try:
		ser = serial.Serial('/dev/tty.usbserial-A6008bXp',9600)
	except:
		ser = serial.Serial('/dev/cu.usbserial-A6008bXp',9600)
	userid = raw_input("userid: ")
	tweet = get_latest_tweet(userid)
	#tweets = get_user_tweets(userid)
	ser.write(str(tweet))
 Read more »

Santa Cruz, Almaden, and an Apple 0

This weekend I escaped to Santa Cruz (by myself) to hang out with Mo. As this was my last week and my internship had ended on Monday, I decided I could spend a bit more time than I normally do there. Mo also invited me to come to watch A Midsummer Night’s Dream with her and the SURF-IT group (UCSC’s REU program) on Thursday night, which would mean I wouldn’t be able to leave until Friday, anyway. San Jose is boring, and I wasn’t about to spend 3 days doing nothing, so I chose to go.

The first thing I did was go directly to Asana, to get some Thai iced tea. I’d just spent two hours riding buses and had actually taken the wrong bus heading in the right direction. By the time I’d found out, I was in Scott’s Valley and needed to cough up another $4 for the correct bus. I at least deserved a tea:

Thai iced tea

Read more »

Next Page »