Monday, January 11, 2010

Ocean Voices


Halsey and I have been hard at work on Roundware this past year. A new version of the server was rolled out, clients for the iPhone and Android are in the works, and a new web-based client was written for our newest project with The California Academy of Sciences.

Today CAS officially announced the launch of
Ocean Voices, an ocean environmental awareness website. Ocean Voices is a collaboration between sound artist Halsey Burgund and marine biologist Wallace J. Nichols.

The idea is to solicit voices from around the world to contribute to an ever-building composition about the ocean and what it means to all of us. You can go to http://www.oceanvoices.org/ now and start telling us what the ocean means to you. Tell us a story of the last time you were in the ocean or perhaps take a shot at explaining where the ocean comes from.

Monday, March 2, 2009

I know it sounds like a ridiculous idea, and before you say anything, it wasn't mine.

How far will a snowball go when thrown from a trebuchet? In all likely hood, you, dear read, have neither the answer to this question, nor any particular interest in knowing it. But if you can believe it, the desire to know the answer to said question drove seven of my friends and I out to the park on a cold winter's day. Armored with coats and sleds we dredged out to the far reaches of Cambridge's own Danehy Park, ready to brave the elements for the promise scientific enlightenment and certain victory.

What force would drive a man to leave the comfort of his home on a mild winter's day merely for such trivia? Madness you may say. Sadly no. As is the case with everything else on my blog, a friend of mine made an off-handed suggestion and I'm impulsive and easily excited. That friend, Dr. Lisa Flanagan, founder of Flanagan Laboratories (LLC) developed and patented a revolutionary new technology for tracking snowballs in the snow.

Finding a snowball in the snow, since it is itself snow, seems an intractable problem at first blush. The impossibility, though never formally proven with any satisfying rigor, was the dominant opinion in the field until Flanagan's work. The details of the method remain a trade secret, and many skeptics have accused Flanagan of fudging her numbers, but as time goes on, the possibility of accurate snowball tracking increases in popular acceptance.

I submit to you the results from the first field test in video form for easy consumption. The video is provided with subtitles for Haze, who is deaf. In fact, you know what? This video is dedicated to Haze, who took a snowball to the head so that we could all laugh just a little bit harder.

Saturday, February 14, 2009

Transitive Relation Limerick

A couple of days ago Randy posted to his blog about going to Limerick, Ireland and also about his Limerick Database project, a great source for some really nerdy limericks. Then last night, Sarah, while cleaning her room, found a really nerdy limerick I wrote about transitive relations. All this, mind you, happening a day after I told Colin that I would make it a point to post to my blog more often.

My blog has regrettably been grossly neglected these past few months. I promise you (and I mean that in the singular sense since I'm fairly certain there is probably only one reader left out there) that this will change very soon. So with out any further, unnecessary back story, here is a limerick to tide you over until I create my next, more substantial post.

If A=B is true
And B=C is too
Transitivity will say
That any which way
If you ever need A, C will do

Tuesday, November 4, 2008

What has 6 wheels, 4 feet, 1 motor, and lots of free time?

It's election day, and one topic that is on a lot of people's minds is energy, oil, and clean transportation. What's the solution? Electric vehicles? Car pooling? Bicycles? Skateboards? Randall Munroe and I decided to try all four at once. Here's a quick video of Randy on his electric skateboard holding onto a nylon strap tied to my bike carrying me holding a camera.

This turns out to be an extremely fun, albeit a little bit scary, method of travel. We all have to do our part to conserve energy. If commuting to work this way is what I have to do, well, I'm comfortable with that.

Wednesday, August 20, 2008

Google Maps developers enjoy extremely long walks through several beaches

It's quite possible that not a lot people reading this post have ever heard of MacDiarmid, Ontario, considering it's so small that I can't even find a population for it. I did find the population of Greenstone, Ontario, the township which encompasses MacDairmid and seven other communities. Greenstone's population is a solid 4,906 people. MacDiarmid is probably among the smaller half being one of four that don't have their own Wikipedia entry. I imagine that this puts their population right around the readership of my blog.

That being said, it's not entirely out of the question that there are MacDiarmid residents reading my blog. Actually it's entirely possible that as soon as this post goes up I will be the first Google search result for MacDiarmid. Especially if I say MacDiarmid enough. Now that I've convinced myself that I'm not totally wasting my time, I'd like to give some navigational advice, if I may, to the people of MacDiarmid.

If you're planning on taking a trip from MacDiarmid to Shebandowan, Ontario, it's a nice, three-hour drive down the Trans Canadian Highway, hugging the shore of scenic Lake Superior. A quick Google Maps look up will provide you with a handy, eight-turn route, and if you leave right after work, you'll be there in time for super.

MacDiarmid has a reputation for being a vacation destination for lovers of the great outdoors. It's likely you may be interesting in planning your Shebandowan trip as a hike or a bike ride. If so it'll probably be pretty tempting to click that new, convenient, little drop down to use Google Map's new walking directions feature. But if you live in MacDiarmid I highly recommend you get a second opinion first. Unless of course you're interested in heading down through the U.S. to circumnavigate the Great Lakes.

The entire walking trip from MacDiarmid to Shebandowan takes a brisk 25 days and 16 hours assuming you don't take any naps or stop for food. It covers 3,203km which is almost 14 times the distance that you'd travel in a car. On your way, you will pass though three U.S. states, take two ferry rides, and visit such major cities as Detroit and Milwaukee. Not to mention two border crossings. Don't forget to bring your passport!

Naively, one would guess that the walking directions from one place to another would be at most as long as the driving directions due to one-way streets and highways that wind around dense areas; this is a bit of city bias speaking. In some cases like these, however, there are un-walkable highways that are the only remotely direct route between two places. Though if you ask me, I'd prefer a little more rough hike through the woods to a 25 day hike with no rest. Maybe Google Maps developers are more adventurous than I am. Maybe they just get more vacation time.

There are definitely pairs of locations that Google considers unable to be connected via walking. I wonder what other kinds trips are possible to walk but have a similarly dramatic factor increase in walking distance. Can anyone find any that are bigger?

Wednesday, July 16, 2008

Catty Scrap Cannon

A couple of weeks ago I was in Pennsylvania with Jeff and Sean, and you know what that means. Destroying things in order to building things which will eventually be used destroy things. A few months ago Sean got a long and very thick steel pipe in at the scrap yard. He saved it aside until Jeff and my next visit with the plans of turning it into a cannon. This sounded pretty dangerous to me so I, as always, was prepared with my camera, just in case anyone got hurt. Have you ever had the experience of hearing such a loud sound that it actually made you temporarily deaf? I think two weeks ago was my first actual experience with this.

Monday, June 9, 2008

Round written up in the NY Times.

I just wanted to post a quick note that Round has been written up by the NY Times. Here's the article on their website.

Monday, May 26, 2008

Province Town Century

If you're not a avid cyclist, a computer programmer, a Free-Software enthusiast, and from around the Boston area, then you've probably never even heard of the Tour De Nat. The Tour De Nat is a one-day, 120 mile bike ride from Boston's South station to Province Town, MA followed by a ride on the day's final ferry back to South Station just in time to go out drinking.

Last summer Owen and I took this ride ourselves with a few adjustments. For starters we didn't plan to take the final ferry back the day we arrived. We planned a camping trip around our ride with several other friends. Secondly, we started from Braintree T station, the end of the Red Line, to cut out the cross-city ride and then took a less-direct, more scenic route across the South Shore.



When we began planning the camping trip, we realized we didn't have many friends who drove, so space in cars was at a premium. We ask the rest of them what was more important to ensure made it to the camp ground safely, the tents or Owen and I. The group unanimously voted on the tents so Owen and I had to find another way to get to the Cape. We spent the next couple of months trying to figure out what to do but with Owen's time warp portal only in pre-Alpha stage and the trebuchet being as weak as it is, we figured the only other option we had was to bike it. At least we wouldn't have to bike with tents.

We spent the summer training. Owen and I went on a 40-mile ride right at the beginning of the summer for a quick warm up. I continued this regiment by spending the summer programming and building things out of PVC while Owen chose to focus more on the riding aspect of the ride for his training. He took several more lengthy, one-day rides over the course of the summer but made to sure to keep me updated so that I wouldn't miss out on that part of the training.

The day of the trip approached and we were ready. We got up at about 5:00am to take the Red Line down to Braintree. We weaved across the South Shore on our circuitous path, hoping to, at some point make it to the Sagamore Bridge. With nothing to guide us but our wits, sense of direction, street signs, highway markers, a map, and a Garmin etrex GPS device, we set off into the great known, bound for adventure or at least a few cramps. We occasionally stopped off along the side of the road to get pictures, take some video.

Let me give you some advice if you're driving a car on route 6A down the Cape. If you see a cyclist riding in front of you, don't assume he's going to turn off any minute now; just pass him. I realize you're old and the road is narrow but seriously, you're holding up a line of ten cars.

Camping in Province Town was a blast. The town has a great strip with lots of nice places to eat and more than its fair share of celebrity look-a-like cross dressers. The beaches were beautiful and if you get to the park services office at 9:00am you can get in line to get a fire permit for the beach of your choice which they will happily give you when they open at 4:00pm.

The ferry ride home was rather expensive but well worth it. For starters, it's a lot quicker than driving or riding a bicycle. Secondly, you can bring your bike on the ferry. One of the things about a century ride is that unless you're lucky, the second half of the ride is pretty much just the first half in reverse. It's nice to be able to take a long ride straight away from your origin and then magically (ferries count as magic) appear back where you started after you're done. The view on the bay was nice and I got a couple nice shots of the Boston skyline as we strolled into the harbor.

That's my report. Owen grabbed our statistics from his GPS device:

Total distance: 108.23
Time moving: 7:44:57
Time elapsed (includes train ride from Davis to Braintree and lunch): 12:30
Average speed: 14.0
Max speed: 31.0

Not bad. We plan to do it again this summer. If you're interested in joining us, let me know.


View Larger Map

Monday, April 21, 2008

What a lot of people don't know about what makes software interesting.

I had a quick conversation with a grocery-store cashier yesterday that stuck with me for a while. He overheard Sarah and I talking about some technical stuff that piqued his interest and it came out that I was a software developer. He seemed pretty interested in that and asked me what kinds of projects I write. I mentioned that most recently I had written software for a museum installation and that for my full time job I work at a software company where I write software for doctor's offices.

His response was what stuck with me. He mentioned how it was nice for me to have some interesting side-projects to fill in the gaps I that must have from my boring day job. I didn't get into this with him due to the brevity of our conversation but I think his response is indicative of a very commonly held misconception about software development.

The irony of it is that if we're just considering the amount of rewarding technical challenges and interesting design decisions, his notions about the two projects are pretty much the exact opposite of reality. As fun an interesting as the museum installation, Round, has been for me, it's really not all that technically interesting. I'm not going to say it was easy for me but most of the reason that it was challenging was for two major issues. The first being that I had to learn a lot of new things as a result of being the only technical person on the project. Secondly I had relatively very little time to cram in all the work since I have another job.

On the other hand when it came to system design decisions, algorithms, abstraction decisions, code organization, or any of the important things we learn in a computer science degree, the decisions on Round were pretty straight forward. This comes in direct contrast to my day job, which I am very happy to say, provides very challenging and interesting problems.

Currently I work on a contract modeling system that enables doctors to analyze the contracts that they have with health-care insurance companies, cross reference them with their billing history, and figure out if they are being underpaid. I'm sure for anyone that is not a computer scientist this sounds incredibly boring. It's actually very fitting that it would considering the nature of the computing world. We invented computers specifically to do our boring work for us. It seems obvious that the work they do would sound boring. It's rare for a computer to get to spend it's CPU cycles on something fun an exciting like playing Chess. Such computers should consider themselves very lucky.

The challenges involved with the contract modeling project range from designing fast algorithms for cross referencing with billing history, creative mechanisms for caching previously computed values when the user will not be slowed down by the computation, and most importantly, the design of a sufficiently expressive language and interface for modeling the contracts that will not destroy the performance of the aforementioned algorithms. The work involves a lot of engineering and creativity as well as a lot of collaboration with other developers and non-developers alike.

Now don't get me wrong, writing Round was very interesting for me. I had total design control over the project, which is always nice and I had some creative input on the user interface and audio. I also learned new technologies which were really fun to use but really the allure to this project was that the result was fun. I was making art and helping my friend see his own art career come to fruition. It was (in direct contrast to my day job) something that my friends could go see and say "Wow, Mike, this project is really cool." It's a project that I personally enjoy using a lot.

Since none of my friends, save Todd, are doctors I don't really get that from my work. Actually I myself have no use for the software that I write at work, but that's not important. It's fascinating and it's solving a real-world problem. The state of health care in the United States, in my opinion, is on the verge of a logistical crisis, and has been for years. The company that I work for, AthenaHealth, is working to fix what it can with really good technology.

It does feel good to be working to solve a problem that effects us all on a political level and it's true that if a company's goals were too far off or even opposed to my own, I would not do the work. But I honestly, feeling good about the cause is mostly an ancillary benefit. For me, it's all about the technical challenge, not the result. I think most programmers would agree with me here. It just goes to show that you really can't conflate how interesting a software project is with how exciting the result is.

Friday, March 21, 2008

Hearing Voices

It's been a long while since my last post. Most of the reason for this is that for the last three months I've spent all of my free time working on a project called Round, which is now on exhibit at the Aldrich Contemporary Art Museum in Ridgefield, CT. Round is an audio installation, by Halsey Burgund, which solicits spoken voice contributions from visitors and uses them as part of a musical composition intended to be listened to while viewing the other exhibitions.

Visitors to the museum can pick up a wireless tablet and a pair of headphones from the front desk. The guard enters in their gender, approximate age, and the fact that they are a visitor into the device before handing it off. The device guides the user through a simple touchscreen interface asking them which exhibit and artwork they are looking at. The device then plays a music piece, composed by Halsey, along with voice comments about the chosen work of art. Users are able to limit the voices by age range, gender, and whether the comments are from the artist, curator, or another visitor.

The mechanism for playing the voice samples is perhaps the most interesting part of Round. Comments are not played in any particular order; they're not even played in their entirety but rather randomly sampled. Come to think of it there's not a whole lot about Round that isn't random. The voice clips are played for a random amount of time, starting from a random point in the clip, with a random amount of dead air between each one. The clips fade in for a random amount of time to a random volume level and then back back out for a random amount of time. There are two separate streams of voices so it's possible to hear more than one voice at a time and each stream randomly pans from left to right as the piece plays.

Round puts the museum visitor into an audio space that transcends time. When you listen to the piece you are hearing everyone who has ever been to the museum and talked about the art that you're looking at. The fading in and out and stereo panning gives the feeling that you're hearing bits of conversations as all the past visitors pass by you.

The exhibit opened this past Sunday so I took the trip down to Connecticut with Halsey, his girlfriend Laura, and an entourage of my nine most supporting friends to go to the reception. Brian's parents happen to live near the museum so Sarah, Emma, Trevor, Owen and I stayed over night. Nicolle, Jeff, Bob, and Chessie all showed up the day of.

Development for Round really came down to the wire. It wasn't until the morning before the opening that I rewrote the entire server to use Icecast rather raw TCP streams in order to make the kiosk version work. During the previous week we discovered that Halsey's commercial audio composition software was crashing if run for more than a few days. And at with just one hour to go before the opening, we discovered that inserting headphones into the device caused the mic to stop working. Now this is something we had tested throughly ahead of time and seemed to be pretty random as to whether or not it happened at all. Dealing with enumerable unforeseeable issues like these is enough to make anyone start hearing voice. Luckily for us that was our goal to begin with.

Despite our nerves, last minute hacks, and never ending surprises, the exhibit actually went really well. The visitors seemed to enjoy it and there were no major technical failures that the users knew about. I can remember my first sigh of relief coming when I saw an early group of visitors walking around the museum listening to the piece. The were listening, smiling, and looking at the art, rather than starring in frustration at a broken device. It felt really good.

After the reception Halsey and I spoke to Lisa Delgado, a reporter from Rhizome, which is an art and technology blog. She wrote an article about the piece called Guided by Voices.

As far as technical details go, Round is developed entirely in Python using GStreamer. The device we're using is Nokia N800, which I chose primarily for the fact that it runs entirely free and open source software. Having a device where one can really open up and hack the internals is pretty critical for any project that's as specialized as Round. Roundware, the software use to run the project, has been released under the GPL at sourceforge.net

After deciding on the device Halsey ventured to send some emails around and see if Nokia might be interested in donating the devices for use at the museum. As it turns out, they did, so Halsey and I would like to extend a big thank you to Nokia for that. I'd also like to thank Owen Williams, a good friend of mine, whose knowledge of Python and GStreamer really helped me expedite my development process. To that end I'd also like to thank the good people of the GStreamer IRC channel and mailing list for their endless patients and key insights.

Finally I'd like to thank my nine awesome friends who took the time to come all the way down to the other side of Connecticut just to see our project and be supportive and Brian's parents for housing all of us for the night.

Monday, January 14, 2008

Catty Scrap Tall Bike

Several weeks ago I was in Pennsylvania visiting my friends Sean and Nicolle again. This time I went down there with a great idea, which, like all of my other great ideas, was actually just a really bad idea backed up with a whole lot of zeal.

The idea was to rummage around in Sean's scrap metal yard for discarded bicycles and weld them together into one giant bicycle. Building a tall bike is a pretty straight-forward process if one has access to just a couple of suitable bike frames and knows how to weld. If one has access and endless supply of unsuitable bike frames and knows someone who has seen someone else weld, the process is significantly less straight forward.

We spent the first day piling up bikes that we found in the yard and discussing plans at the Allentown Brew Works, which was hosting their annual Brew Fest while I was in town. Keep in mind, inspiration comes faster when you're drunk and in Pennsylvania. I had found a couple of similar size BMX bikes and noticed that they both had those distinctive four-bolt handle-bar clamps and the handle bars with a cross bar on top. Sean and I decided it would be cool to take one BMX bike and flip it up-side down on top of another BMX bike. We'd take the handle bars off of the top one and use its clamp to hold onto the cross bar of the bottom bike's handle bars.

I thought that if we did this, the two seat tubes would line up and I'd be able to put a seat post through both to connect them, but I was wrong. So we took the plastic off of one seat and arc welded the remaining metal wire to the up-side-down bike. This allowed us to connect a regular seat tube to the top bike and slide it into the seat post of the bottom bike. I like to think of it as a bike that has a bike for a seat.

We then had a bike with pedals three feet off the ground, a fork for handle bars, and no place to sit. We solved the handle-bar problem no sweat. We just took another fork and connected it right-side up to the up-side down one. The existing wheel and axle made a perfect connector for the two forks so that's why there's a decorative, fourth wheel on top of the bike.

Now for the real challenge, where do you sit? We both agreed that putting my weight on that little seat-wire-welding number we whipped up earlier would probably cause my death, so we decided to cut the seat tube off of another bike and weld it up right coming out of the bottom bike. To brace it we drilled a huge hole through the bottom bracket of that same bike to put the seat tube through and welded the chain stays to the bottom bike for support. We found an extra long seat post in the yard to toss in there and presto! A very high seat.

Then we realized the major problem. The frame was in the way of running a chain from the crank to the rear hub because it was designed to have the chain go out the back. Now anyone reading this is probably thinking to themselves "Oh that's easy. Put the top bike's chain stays in a vice over night and force them apart. Then stick a five-speed mountain bike wheel with a cassette in the newly widened frame, run a chain from the crank back to the cassette, and finally run a second chain from the cassette down to the rear hub." Now, I admit that, in retrospect, we should have thought of that sooner but it was late and we weren't really thinking all that clearly (which we probably can't blame on the late hour.)

The bike was complete and there was only one thing left to do. I put on some thick gloves in case I had to brace myself during a fall and Nicolle got ready with the video camera in case anything more dangerous happened. As soon as I got on for the first time it was obvious that the bike would immediately do a wheely if I put any weight on the seat. It was so high up that it was behind the rear wheel, causing the seat post to act like a big lever. So we figured what, the heck? Toss a couple 20 lbs. weights on the front handle bars. It's not like we're going to being winning the Tour de France on this thing.

The first few trial rides revealed a flaw in the vertical chain. There was no way to tension the chain so it kept falling off. We added a derailer to try to pull up the slack. This fixed the problem enough to ride but it was still error prone and fell off fairly often causing the bike to lose speed, stall, and ditch its pilot.

We ended up using parts from six different bikes, two whole frames, one extra fork, one set of hacked up frame parts, an extra five-speed hub, a derailer, a seat, and a bunch of spare chains. I admit it wasn't pretty but it was so beautiful. Next time I visit we'll try to fix the chain situation.

Thursday, December 27, 2007

The absolute crux of AJAX. A short, short tutorial.

I've been unbelievably busy this past month so I haven't had much time to post any of the things I've been doing. I did, however, have to learn a little AJAX in order to complete a side project of mine. Since I found it a little difficult to find exactly what I needed easily on the web I wanted to share what I learned with anyone who might be Google-searching for how to write AJAX web pages.

First, a quick motivation for the problem. I want to give my user an entry form to tell me which country they are from. Once filled in, I want to populate a selection box for the region they are from, which of course depends on which country they select. After that I wanted them to chose the city. One really simple way to accomplish this is just to write out a list of all the countries, regions, and cities into a Javascript data structure. The problem is that there are more that 36,000 cities in the database I was using. Writing this all out to the user at once would make their browser time out.

What I really want to do is give the user just the countries to chose from first. Once they have chosen a country, I get the regions for just that country out of the database. Javascript doesn't have any database bindings and I don't want to have the user submit the page and have a new one come up for UI reasons.

What I want is for Javascript to go and ask the server itself. This is what AJAX is for. After reading a tutorial or two and picking out the pieces I needed, I found that this little snippet of code is all I need to do:


var req = new XMLHttpRequest();
req.open("GET", "getregions?countryid=" + countryid, true);
req.onreadystatechange = function () {
if (req.readyState == 4 /*complete*/) {
var data = eval('(' + req.responseText + ')');
... do something with data ...
}
req.send(/*no params*/null);


I simply create an XMLHttpRequest object. XMLHttpRequest is the Firefox version of the object. Different browsers require different objects, sadly. You can find out more about how to handle this problem here. Next I call the open method to connect to a script that I wrote to get a list of regions given a countryid. This program can be written in any language you want and acts just like any other CGI program. Instead of printing out HTML it prints out JSON. Most modern languages have a library for printing JSON or you can simply print it out using your own string building. You can learn more about what JSON looks like at json.org.

On the third line I set up an anonymous function to handle the network connection. It is called whenever the state is updated, waits until it's done, and then evaluates the JSON text into internal Javascript data. The function is then ultimately responsible for actually doing something with the data.

The readyState of the XMLHttpRequest object of course has more possible states than just 'complete'. If you'd like to learn how to deal with other states for make a progress bar or handling errors, then you can read more about the XMLHttpRequest object at w3schools.

The last line uses the send method to set the whole process in motion.

That's it. That's how AJAX and JSON work. Hopefully this tutorial will act as a decent spring board for anyone who wants to learn AJAX. There's a lot more out there of course and I've only really glazed over it. But if you need to get something up and running quickly this should do just fine.

Thursday, November 22, 2007

I have ended world hunger

I'm a computer programmer by trade and more importantly I'm a problem solver by nature. When I am presented with a problem, however minor, I can't help but try to think of ways to solve it.

Two weeks ago I posted an entry called "You are the paramount computer technician without letup!", wherein I wrote a program, called PamFRI, to solve a problem that my friend, Pam, was having with her keyboard. I got a lot of comments from people claiming that the program was "useless". The program solved a problem that only one person had and she wouldn't even have the problem the on following day. Furthermore, it didn't even actually solve the problem since it's impossible to use the program if you have the problem. Alright, to be fair it was me that said all those things but I just can't handle criticism, regardless of how self-inflicted it may be.

Feeling like my reputation as a computer programmer was on the line I knew I had to rewrite the program. This time I decided to be a little more ambitious and end world hunger.

(require
(planet "csv.ss" ("neil" "csv.plt" 1 1))
(planet "sxml.ss" ("lizorkin" "sxml.plt" 1 4))
(planet "htmlprag.ss" ("neil" "htmlprag.plt" 1 3))
(planet "aif.ss" ("schematics" "macro.plt" 1 0))
(only (lib "1.ss" "srfi") list-index)
(lib "uri-codec.ss" "net")
(lib "url.ss" "net")
(lib "etc.ss")
(lib "list.ss")
(lib "string.ss"))

(define thesaurus
(let ([table (make-hash-table 'equal)]
[get-line
(make-csv-reader
(open-input-file "mobythes.aur")
'((separator-chars . (#\,))
(strip-leading-whitespace? . #t)
(strip-trailing-whitespace? . #t)))])
(let loop ([line (get-line)])
(unless (empty? line)
(let ([word (first line)])
(string-lowercase! word)
(hash-table-put! table word (rest line))
(loop (get-line)))))
table))

(define (post url data)
(html->sxml
(post-pure-port
(string->url url)
(string->bytes/utf-8 (alist->form-urlencoded data)))))

(define (check word options)
(foldl
(lambda (synonym ans)
(if (member synonym options) synonym ans))
false
(hash-table-get thesaurus word (lambda () empty))))

(define ((sxpath/f path) sxml)
(first ((sxpath path) sxml)))

(define (answer page)
(let* ([words ((sxpath "//div/div/ol/li") page)]
[word ((sxpath/f "strong/text()") (first words))]
[choices (map (sxpath/f "a/text()") (rest words))]
[answer
(number->string
(add1
(aif ans identity (check word choices)
(list-index (lambda (e) (string=? e ans))
choices)
(random 4))))])
(cons
(cons 'SELECTED answer)
(map (lambda (tag)
(cons (string->symbol
((sxpath/f "@name/text()") tag))
((sxpath/f "@value/text()") tag)))
((sxpath
"//input[@type='hidden' and @name!='SELECTED']")
page)))))

(let loop ([data empty])
(let ([p (post "http://freerice.com/index.php" data)])
(write ((sxpath "//p[@class='vocabLevel']/text()") p))
(newline)
(sleep 10)
(loop (answer p))))


Inspiration for this program came last week, right after I wrote PamFRI. One of my coworkers, Fred Henle, sent out a nice, little time waster know as Free Rice to the developers' mailing list. Free Rice is a non-profit web site where users are given a vocabulary quiz. For every answer the user gets right, the organization donates ten grains of rice to third-world countries through the UN.

Moments after Fred's email, Ben Mathes responded with his solution to end world hunger: a link to dictionary.com. As soon as I got Ben's mail it was pretty obvious to me what I had to do. "I can automate that!" I thought to myself. I had just written PamFRI, which uses a machine-readable thesaurus and PLT Scheme has a really nice web-scraping module on Planet. With only a few more lines of code I could modify my original program to grab the web page, read and answer the question, and then post it back. Calling such a program in a loop ought donate a lot of rice and would, at least in theory, end world hunger.

It's probably not advisable for me to encourage my readers to run this program since it generates a page hit to Free Rice once every ten seconds. If everyone one of my readers ran this program at the same time it could generate up to five page hits to Free Rice every ten seconds. On second thought, maybe that's not so bad. My friend, Trevor, points out that the real danger is when the OLPC project really takes off. We'll have ourselves a veritable DDoS attack if this program were to get into the hands of the kids who actually benefit from the rice donations.

On a serious note, the real reason I wrote this entry is to let people know about Free Rice and encourage them to play for real. I also wanted to show how darn cool the webscrape functionality is in PLT Scheme in case anyone has any need for it.

Monday, November 19, 2007

Six Degrees of Wikipedia is On Line

Last month I posted an entry called Six Degrees of Wikipedia, where in I started playing a game in which people try to find the shortest path between two given Wikipedia pages. My friend Colin made a random node generation script and yesterday we created a new web site where we will administer the game. Periodically a new challenge to connect two Wikipedia pages (by Wikipedia-internal links) will be issued. The first one is already up, so get cracking. The winners will be announced when the next challenge is release. Enjoy! Oh and hey, no editing the pages so that your path works.

Extra credit for people who write solvers or know how to use Google to find such things. :) I mean the Kevin Bacon game is still fun despite the existence of solvers, right?

Go to: http://sixdegreesofwikipedia.blogspot.com/ to play.

Friday, November 9, 2007

"You are the paramount computer technician without letup!"

Have you ever you spilled water on your keyboard? Have you ever shorted out the F, R, and I keys on your iBook all at once? Have you ever had to chat under such circumstances because you couldn't get an appointment at the Apple Store until tomorrow? Is your name Pamela Worth? Are you chatting with me right now on instant messenger? Maybe it's time you tried the latest in useless technology. That's right, maybe PamFRI is perfect for you!

Earlier today I was talking to my friend, Pam, on line and she seemed to be speaking rather funny.

me: How are you?
Pamela: well, apart from not hav1ng some very important letters not working...
me: You're 'i' key is broken?
Pamela: 3 keys
f, r, i
Pam has app't 2moro to see Mac "gen1uses"
me: How did it break? Mysteriously?
Pamela: not so Mysteriously.
1 sp1lled a small amount of H20


Intermittently a few of her keys would not work so she was resorting to l33t speak, cutting and pasting my own words back to me, using chemical formula abbreviations, or simply referring to herself in the third person. So I did what any good, overly nerdy friend would do in that situation.


grep -vi "[fri]" /usr/dict/words | mutt -s "Here's a list of words that don't use F, R, or I" [Pam's email address]


But as you can probably imagine, a list of all of the words in the English language that don't use the letters F, R, or I isn't all that useful. For starters one would have to search the entire list of words and the definitions aren't even there.

I simply had to do more to help the poor girl, so I helped how any good, super geeky friend would help. I made a small program that uses a machine readable thesaurus from the Moby project to accept a sentence that you want to type, as well as a list of keys that are broken. The program searches the sentence for any uses of the broken keys and swaps them out for suitable synonyms that don't also use the broken keys. In the event there are no suitable synonmys, the word gets printed out with square brackets. I call it PamFRI.

If you're wondering what the above paragraph looks like without the letter's F, R, or I:

Ego absolutely had to do on and on to help the debased dame, so psyche helped how any good, hot geeky bosom buddy would help. Monad made a small agenda that uses a jalopy plumbable cache ex the Moby lay plans to accept a sentence that you want to type, as well as a levy about jolty keys. The keynote speech looks down the sentence so as to any uses about the wobbly keys and swaps them out because plenty good enough synonyms that don't also use the quelled keys. Gangplank the event no seasonable synonmys can be etch, the vow gets typeset out amongst yes-man [brackets]. One and only call the goods [PamFRI].

(require
(planet "csv.ss" ("neil" "csv.plt" 1 1))
(lib "list.ss")
(lib "string.ss"))

(define thesaurus
(let ([table (make-hash-table 'equal)]
[get-line
(make-csv-reader
(open-input-file "mobythes.aur")
'((separator-chars . (#\,))
(strip-leading-whitespace? . #t)
(strip-trailing-whitespace? . #t)))])
(let loop ([line (get-line)])
(unless (empty? line)
(let ([word (first line)])
(string-lowercase! word)
(hash-table-put! table word (rest line))
(loop (get-line)))))
table))

(define (suggest badchars sentence)
(regexp-replace*
"[a-zA-Z'\\-]+"
sentence
(lambda (aword)
(string-lowercase! aword)
(if ((typeable? badchars) aword)
aword
(replacement badchars aword)))))

(define ((typeable? badchars) aword)
(not (regexp-match
(regexp
(string-append
"(?i:[" (list->string badchars) "])"))
aword)))

(define (replacement badchars aword)
(let* ([synonyms
(hash-table-get
thesaurus aword (lambda () empty))]
[replacements
(filter (typeable? badchars) synonyms)])
(if (empty? replacements)
(string-append "[" aword "]")
(list-ref replacements
(random (length replacements))))))


You call the program like this:

> (suggest '(#\h) "hello my name is")
"salutation my name is"
> (suggest '(#\h #\n) "hello my name is")
"kiss my itemize is"
> (suggest '(#\i) "I like the program very much")
"superego respect the program very much"


So if you're a clumsy, water drinking, Apple computing, debased dame, fear not. Help is on the way. You can download the program here in a zip format complete with the thesaurus. The program requires Dr. Scheme to be opened which is availible for Linux, Mac, and Windows.

By the way, I fully intend to continue calling them 'yes-man brackets'.

Thursday, November 8, 2007

I'm a grown-up now

A little more than a year ago Randall Munroe, author of XKCD, posted a comic, called Grownups, about a girl filling her apartment with playpen balls. The girl in the comic offers no explanation as to why she's done this, other than the fact that she's a grow-up now and it's her turn to decide what being a grown-up means. The whimsical web comic has often portrayed a state of mind that hits very close to home for me and this strip wasn't an exception.

I'm impulsive so I started looking on line for playpen balls the following weekend and quickly learned the same thing Randall did. Filling one's apartment with playpen balls, for any reasonably sized apartment, or even a tiny dorm room, would cost well over a few thousand dollars. Determined to have a ball pit, I decided I would cordon off the bottom of my lofted bed and make a ball-pit underneath. The lofted bed is a nice big queen-sized bed so the pit would be about 5'x7' with about 5' head clearance.

Using an on-line playpen ball volume calculator (inspired by the XKCD comic itself) I found that making a 5'x7' ball pit 2' deep was a pretty tractable goal. With a little help from my friend Sue I was able to find two ebay auctions for 700 and 800 balls from the same seller. The orders totaled about $160 counting shipping, which by the way made up more than 40% of the cost.

I placed a bid and week or so later I received the largest delivery I'd ever received as well as an endearingly spastic but uninformative voice from my roommate attempting to describe exactly what had happened to our front porch while I was gone. "Hey! Mike! Oh my god there's, like... the porch is totally gone. They're huge. These all have your name... I can't... do want me to... Holy crap." Remembering my order from a week ago I figured that was probably what she was talking about so I went home to bring them in.

On the Saturday after the delivery arrived, Sue and I went to Home Depot, the toy store for grown-ups who think the word grown-up has been ill defined. After some careful consideration we decided to pick up a reel of plastic garden fencing, zip ties, and you guessed it, some PVC pipe.

The lofted bed was already up against two walls so I just needed to gate off the other two. One wall, the short one, I decided to completely cover with the garden fence. The long wall I made the entry way, so it has a short wall made of a PVC frame and garden fence which is easy to step over.

That Saturday night Sarah came over and Sue, Sarah, and I sat in the ball pit for nearly five hours talking and laughing uncontrollably while throwing balls at each others faces. It really is quite amazing how long throwing balls at your friends' faces can last without getting boring. When it did we just lounged around and chatted until someone decided it was again time to throw balls at each other's faces. As the night winded down Sarah took great joy in completely burying herself and Sue made sure that both of us had heard every possibly innuendo involving the word balls.

Later in the week my improv troupe came over to practice and we ended the night with a really loud and rowdy ball pit fight where in most people just threw balls at Tony while Tony scrambled to bury his face and anything else fragile under a thick enough covering of playpen balls. My more obsessive compulsive friends came over the following weekend and we shorted the ball pit in spectrum order. To be fair this project also started with throwing balls at each others faces when I decided that Mike could only throw blue balls and Trevor could only throw red. This created a really nice visual effect so we ran with it and Lisa took some pictures.

I guess what I've learned from all this is simply that if you are going to go through the trouble of making a ball pit in your apartment just realize that all your friends are going to want to do is throw plastic balls at your face. Recently I moved and decided to make a video of the reconstruction of the ball pit.

Wednesday, October 10, 2007

Six Degrees of Wikipedia

Last night, Sarah and I were watching an episode of Northern Exposure when I noticed that the door to the local radio station displayed "KBHR 57 AM". From what I knew of AM radio, the range used by commercial stations in the US was in the upper hundreds to thousands, nothing near 57. So I looked up Amplitude Modulation, AM, on Wikipedia and soon found I had to click on AM Radio to get the answer that I wanted.

I started thinking about all the long link chains I've followed in the pursuit of useless knowledge and about that XKCD comic about wikipedia surfing. So naturally my next inclination was "I wonder how many clicks it will take me to get to Kevin Bacon's wikipedia page. Honestly, I thought it would take longer than it did. Little did I know there was a link to the movie Titanic on the page for the United States. I never would have guessed. This is what we did:

Amplitude Modulation to AM broadcasting to United States to Titanic to Leonardo DiCaprio to Catch Me If You Can to Tom Hanks to Apollo 13 to Kevin Bacon

Can anyone do it in fewer moves? I bet there's a shorter route if you don't take the easy way out and go straight for the nearest link to a Hollywood movie. I think this game has some potential as a non-movie-centric version of it's namesake. Okay what you lazy readers need now is a challenge. Hang on.

Me: "Trevor, Brian, think of a topic that you could look up on Wikipeida, but don't say it."
Trevor: "Got one."
Brain: "Alright."
Me: "Okay, what are they?"
Brain: "King Arthur"
Trevor: "Sickle Cell Anemia"

King Arthur will be the starting point since this game isn't commutative like the Bacon game. Post your best answers to the comments.

Wednesday, September 26, 2007

How I Accidentally Joined a Bike Gang

Late last Saturday night Pascal and I were riding through Davis Square, heading to a party, when a fleet of intergalactic transport ships flanked us at a traffic light.
"Hey, nice bike!" said a Skunk, four feet above me.
"Thanks. You too!" I said as I looked up to admire his Cloudbuster.

"Now these are my people." I thought to myself as the light turned green and we all rode down Elm Street. We got to talking about bicycles, art, how to make PVC hinges, and the finer points of welding a disco ball to ones handlebars. They had plenty of questions for me and I for them.

I dropped back a little and met up with the fleet's tailgunner, Dozer, who explained to me a little bit about how the organization works. A lot of people know about or at least have seen SCUL around Somerville and Cambridge. They're a non-profit, artistic, bicycling, nerd gang based in Somerville, MA. They have missions once a week on Saturday nights which launch from a secret base and head off into the galaxy, blasting dance music from the fleets flag ship.

"The way it works is that you get invited to join by a member who's willing to sponsor you." Dozer explained while Pascal took notes. "You become their maggot for your first ride and your sponsor shows you the ropes dur... hang on." She banked quickly off to the right to pick up a set of brief, metacrapal connections at a high-five refueling station that materialized on the sidewalk near Porter Square's White Hen Pantry.

As we road on through Harvard Square collecting more high fives, cheers, and car horn blasts I learned about Operation Back in the Saddle Again and their objective for the night. The fleet was destined for Riverside subway station, the end of the Green Line's D branch, out in Newton, MA. The objective was to catch a glimpse of the stations planet Pluto model installed by the museum of science.

We road on through the night, out to Watertown, MA to a 7/11 to collect juice and candy bar rations for the mid-flight pit stop. We also had to make a few repairs. One of the maggots, Dishpan, altered the crew that her ship, War, had a wobbly wheel. Now, a little wobble never hurt anyone, but with a name like 'War' and three-foot ramrod mounted to your front, a wobbly back wheel can totally destroy your street cred. Threespeed, the fleet's resident mechanic aboard Starhustler, got out his tools and gave War a little once over. Dishpan then road three-quarter speed into a chain link fence head on with the ramrod repeatedly until she was satisfied that War had regained his original gusto. I went to talk to Skunk.

Skunk and I discussed hacking and the DIY community for a while and I was invited to next week's mission to a non-disclosed location which will be of particular interest to a hacker electronics geek like myself.

Now if you have good reading comprehension you've probably been think to yourself this whole time "Didn't he say he was headed to a party? How much time has passed since the beginning of this story?" Well yes, I was headed to a party, a party back in Davis Square no less. About an hour or two had gone by during our ride and pit stop and I was expected hours ago. So I bid my new friends good bye and wished them much luck on the remainder of their journey.

I've been instructed to send Skunk and email for more information and Dozer said she'd be happy to sponsor me on my first ride. I'm pretty excited and looking forward to exploring the galaxy in style next week; we'll see how it goes. The import thing to take away from this story is that I will soon be in a bike gang. One with secret meeting spots and all sorts of midnight shadiness. Needless to say I am certainly no longer someone to be trifled with.

Wednesday, September 12, 2007

Dr. Scheme, you complete me

My roommate, Amy, has been doing an indexing project for a company as a private contractor. The job involves a lot of data entry so I ask, as I always do, if there are applications for custom software in the project. Nothing bothers me more than seeing people doing work that a computer could be doing.

I wrote a program to aid in her data entry which included a quick, hundred-line hack to do auto-completion. I sent it to my friend Jacob for comments who sent it to his adviser Robby, who was my adviser when I worked full time as a research assistant for the PLT. Robby had a lot of suggestions to make it a lot prettier and lot more user-friendly, all of which Jacob has since implement.

After Jacob's handy work the code went into the core DrScheme framework. Auto-completion was one of the most requested features for Dr. Scheme so we're all pretty excited that it's finally in there. Robby posted a blog entry to the PLT Scheme Blog announcing the features and there was much rejoicing. A party was thrown, prizes have been awarded, two volcanoes erupted, and parade is planned for next Sunday.

Monday, September 10, 2007

How to Make Friends

This past weekend I went to Home Depot with a tape measure, some written measurements, and the intention of getting shelves for my closet. But as usual, I ended up wasting a lot more time than I should in the plumbing section. Literally four hours went by as I played with various PVC connectors like five-year-old at Toys R Us. I decided to take a break from setting up my new room and what better way to do this than to build a life-size stick figure out of PVC pipe to ride on the back of my tandem bicycle?

I walked around the aisle, measuring my arms, legs, and torso, drawing pictures, and laying pipes out on the floor in a roughly humanoid form.
"Do you need help?" one employee asked, choosing his words diplomatically.
"Yes", I said. "Do you have cross-joint for one-inch by half-inch by one-inch by two-inch PVC?"
"I doubt it, considering the way water flows. We don't carry every piece so it's hard to find things that aren't used for typical plumbing setups." He looked down at my head on a stick "And that is clearly not plumbing related."

I adjusted my plans accordingly, swapping out pieces in my drawings for the ones they actually carried in the store. Since I didn't know how big he'd need to be to fit properly on the bike I just modeled his sizes after my own. This is why his biceps are a half of an inch in diameter.

Later I went home to saw and cement together my new friend. After much deliberation with my roommate, Amy, we decided to call him Pascal Vanderbilt Chesterfield. I think it's a pretty fitting and dignified name.

Having a tandem copilot automaton around has a lot of benefits that you might not realize. I can finally ride in the carpool lane when I'm biking to work on i93. If none of my friends are around to go for a ride on the weekends I can still go without looking completely ridiculous. It's a lot less awkward if I meet a girl at a bar and she has a friend made of PVC. And best of all, he can wear the backpack instead of me. Now I just need to teach him how to signal.