March 2007

Nike++

I got tired of Nike’s flash-based UI and I wanted to learn Ruby on Rails, so I’ve started work on a little RoR web app that allows people to create accounts, upload Nike+ XML files, and view their runs. To view an example, just log in as geoff with the password geoff. This thing is definitely a work in progress, but if you want to screw around with the code you can download it here. The easiest way to deploy and test everything would probably be to just generate a generic Rails app and then copy the app directory over. If you want to try uploading runs but you don’t have an iPod sport kit, use the XML files here for testing.

Computers

Comments (0)

Permalink

XML Parsing in Ruby

I've recently started learning Ruby (and Rails) after seeing a coworker use RoR to quickly throw together a web app with all the goodies: AJAX, MySQL backend, pretty Web 2.0 theme, etc. I've gotten rather tired of Nike's flash-based web app for their iPod sport kit, so I decided parsing the XML files on my iPod Nano would be good Ruby practice and familiarize me with Nike's XML. I threw together a quick script that parses the Nike+iPod data and prints it out. You can get it here. If you're too lazy to copy one of the XML files off your iPod (or too lazy to run, or too poor/nonconformist to buy an iPod, etc), I've also got a test file. I haven't tried XML parsing in too many other languages, but Ruby makes it pretty easy. Iterating over a bunch of the same kind of elements is very handy. I'm working on turning this into a full web app that lets you upload XML files and track your runs (basically a version of Nike's website without the suck), but I don't think it's ready yet. When I get it closer to done I'll make the SVN repo public and set up a production copy.

Computers

Comments (0)

Permalink

Keep it simple, stupid.

I was asked to write a linked list in C++ at a job interview today. Immediately I started working on classes and methods and whatnot, but I didn’t have enough time to get it fully working. I gave a poor impression and had to explain inserting into and deleting from linked lists on paper. Afterwards, I realized my interviewer didn’t want a heavy object-oriented linked list. He wanted to make sure I knew the concept (and pointers in C++). A simple struct node and a couple of loops would have done the job.

When I got home, I was compelled to finish what I started. I made the linked list anyway to prove to myself I could do it. Here’s the Xcode project and everything else that’s necessary. Obviously you don’t need Xcode. Compiling main.cpp should do the trick on pretty much any system.

The linked list only has an AddToFront, DeleteFromFront, Next, and GoBackToFront methods, since that’s about all you can do with a singly linked list. I used templates so the thing could actually be useful if not for the total lack of documentation and testing. (Not to mention the fact that everyone writes one of these.) It does have an educational purpose though: Since I made it spit output when nodes are added and deleted, you can see how the destructor is implicitly called once the test object is out of scope. (In this case it’s when the program ends.) Writing this really took me back to my data structures class. I guess I’ve become soft since most languages come with nice data structures.

Computers

Comments (2)

Permalink