Sunday, December 30, 2007

Doctor HP Says: Howdy!

I wrote this in January (1/13/07) responding to a personal ad on craigslist and I stumbled onto it while looking for a contact at HP, somebody I met at RIT in the Golisano College who had a pretty interesting chat with me about language and computational linguistics. If that guy was a doctor, he might have meant to diagnose me.

I think he was saying something like this: save yourself!

This photo is pretty representative of my personality: the cigarette-smoking buddha. It's a vile habit of course, that I haven't quite kicked completely. There's no good reason for that, but I've got plenty of excuses if you're interested:

In my defense, I was voted "Scholar of the Year" in my fraternity... read that again if it doesn't sound like the Oxymoron of the Year. Point being I'm living alone for the first time in my life, since October. I don't see much of my friends (the best of them are smokers), and when I do, I tend to go to great lengths to relate.

That being said, if you and I are to meet in person, I will certainly be very self-conscious of smelling like smoke, and I'm likely not to smoke for at least 48 hours in advance! I'm generally a pretty quiet person in person, don't really like to talk about myself as I feel like I end up repeating the same resume/laundry list every time. Perhaps I'm in an introverted phase of my life right now, but I am a great listener and I enjoy talking one-on-one, and getting to know good people.

I'm not really into video games but I think it's great that you are! I had my fill of playing games constantly in high school, but I do a lot of watching (erm, call it research) when I visit with friends... the coolest game I have seen lately is Guitar Hero, and the most highly overrated is certainly World of Warcraft.

What a crock. Computers are awful for your personal well-being. At least my brothers are smart enough to spell my name wrong on the Scholar of the Year plaque. GO PHI DELT!

Travel Toronto!

Your Chinese lesson/word of the day, care of something I overheard a dude say while he was on the telephone in the bathroom at Spirits:

漂亮: piàoliàng - beautiful

How incredibly discourteous of me! First I was eavesdropping while taking a piss, then worse yet I had the nerve to repeat what I heard on the internet?

Probably not a completely wasted trip, while I was in town I met a guy from Korea smoking cigarettes at a gas station (live dangerously) that said he had worked an Advertising job at Adobe. He was pretty cool! I hope he made his bus :D

Wednesday, December 26, 2007

Wordpress is Sweet!

Sweet guys, Wordpress is sweet. I can't stand how sweet it is, anyway I thought I'd let you know that it's just not working out between you and me, and I like that one better. Don't take it personally, unless you're insecure about your person, I just like that one better than this one. XOXOXO

Monday, December 17, 2007

Personal Todo

"I spent all day Friday trying to get my environment working! I wasted an entire day. How do they expect us to get any development working if we can't get a stable development environment?" -- overheard from the other side of a cubicle wall at a nameless company.

So I spent $100 a little while back on a toy for myself. I mean it's not so much a toy, as an investment. OK so it's a toy, but a well-designed useful toy that is very helpful for expressing the frustration you might experience as a developer.

It's one of those neat little Sidekick things. It doesn't do anything worthwhile, besides taking pictures on a MicroSD card at 1280x1024 pixels. It has a simple notepad, a task organizer and a calendar, which lose all of their data as soon as the battery runs out. Without a service plan, it's really not much of an organizer at all.

So then why do I call it an investment? Because it doesn't charge me $70 every month for the privilege of using it. My Verizon phone reliably sends me a bill every month, and still, the most frequent caller is this fellow Sultan from Saudi Arabia, whose calls get forwarded from my Skype account. These days you don't need a mobile phone any more than you need OnStar.

We hold these truths to be self evident: you can talk to your friends face to face. Except when you can't, then you can use the Internet.

Apparently they are holding on tight to the Sidekick developer keys these days, because it turns out that if you have one you can actually circumvent all of the copyright protections on the device and run any subscription-based programs (that you or your friend probably bought and paid for at least once) without paying a recurring subscription fee.

Are there any other developers out there like myself that think this sounds like a good thing? Subscription software is the road to a never-ending pyramid game. I don't want to go down that road, I just want to pay the bills so I can live indoors and eat food! And, you know, maybe take a couple of days for traveling every once in a while.

Anyway, I want something to do with my free time, and I'd like to believe it might make some money one day. The Danger team says I have to provide some evidence that I am a developer to receive a developer key. They've provided lots of well-organized documentation and a simulator that I can run on my own computer.

To hook all of my devices together and make them do my bidding, they are asking that I demonstrate some competency in that skill. All they want in return for building the device is a slightly new idea and an implementation, and they have promised to respond in kind with a developer key and further support regarding sales and marketing. Now I've got a pretty good idea for them, and I might even have time and expertise to implement it myself.

The project: integrate a set from the toys listed below, and come up with a cool name to call the resulting program by... here's the list: bluetooth, tomboy/wiki, sidekick/hiptop, java, groceries/recipes, collaborative team sharing, web desktop. Come again? I want a [java] program simulating the popular Tomboy application for Linux (it's a personal wiki).

I want it to run on my Danger Hip-top and synchronize with my desktop computer across a Blue-Tooth link. I want to keep my grocery list on it, I'd love it to integrate with Quickbooks for expense reporting, and it should also have a sharing component to make selected pages available to a team of people with (or without) danger Hip-tops. There should be a desktop component with a similar interface, or at least a web interface that authenticates by e-mail address.

Read about D-Bus, I think these concepts are important.

And sorry folks, the UI testing work and Blackjack simulator that I promised have been delayed again. Turns out the most useful tool, FolderShare, is in fact blocked by name from the corporate firewalls. Good thing I spent so many months working with Subversion, but it's still not end-user easy. I wonder if I'll have any more luck with iFolder when I get that up and running.

Hopefully we'll have more news before next weekend... I want to start a group discussion on Saturday or Sunday on one or the other project.

Wednesday, December 5, 2007

Hibernate Tutorial Review

I'm starting my co-op at Thomson West this week, and things are going swimmingly! I've been introduced to a handful of interesting people and perhaps twice as many new frameworks, some of both that I had never heard of before. Trying to narrow the focus just a little bit and learn something while I've got some downtime on my hands, I haven't been assigned to a particular project yet so I'm going to make my own with an initial focus on the Hibernate library for Java.

Hibernate is a layer that enables creation of persistent objects in Java applications, using a JDBC database as the backing storage layer. I meant to use PostgreSQL as my backing database because it is known as the most advanced database and it is also free, but the tutorial that I am following is based on HSQL, a simple lightweight native Java database engine, so I'm running with that until I have a reason to change it out.

The code is all copied here, all dependent libraries are included for simplicity (exclusively for educational purposes; I have not reviewed the licenses but I'm pretty sure this is non-infringing educational use.) The JDBC drivers are not included as far as I know, you will have to install HSQLDB or PostgreSQL for yourself if you want to follow my tracks and learn with me.

Hibernate code is database-agnostic, a single change in the file hibernate.cfg.xml will alter the storage backend of the app, and that's all it takes to swap out your database for another one. Something like a schema is evident in the file Event.hbm.xml, the hibernate-mapping file, which describes the mapping of objects to database entries for Hibernate.

Hibernate-test01\data\> java -classpath ..\lib\hsqldb.jar org.hsqldb.Server

HSQLDB just runs in a command-line console and you can terminate it when you're done working. Modify the options in hibernate.cfg.xml for hbm2ddl if you want to re-seed the database with fresh tables (maybe you have updated the Event class to include some new data fields and you have modified the hibernate-mapping information, so now the database schema is out of sync.) You will lose any data that you have generated, so it is recommended not to do this in the middle of an experimental trial!

So, now that we've had enough technical jargon to kill a small animal, what does this code do and how can you tinker with it? There are three important classes for which new code has been defined: Event, EventManager, and HibernateUtil.

Event is what is called a JavaBean, that is to say it is very simple in function and supports little else besides manipulation of various data fields; for each Event on our hypothetical calendar, a new Event object is created with a Date, String title, and Long id. These fields are again defined in the hibernate-mapping file Event.hbm.xml, with mappings to columns in a database table.

EventManager is also pretty lightweight, though it is actually doing a lot of work thanks to the support code in Hibernate. The main execution test is in this file, with only two options: list the events in the database, or store a new event with the current time and a default title. The EventManager code does not know about any database, only talks about a Session and from the documentation the current session is associated with the current thread of execution.

To create and store an event:

  1. Get the current session object out of HibernateUtil class
  2. Start a transaction
  3. Create an Event object and populate the data fields
  4. Save the object in the current session
  5. Get the transaction again and commit it back to the database
To show all of the currently listed events:
  1. Get the current session object
  2. Start a transaction
  3. Create a query on the session to grab a List of all objects from the Event table
  4. Commit the transaction and return the resulting List of Events
This leaves HibernateUtil, whose operation is dead simple: instantiate a SessionFactory based on the options in the hibernate configuration file, and hang on to it until EventManager asks for the current Session object. As long as our program is single-threaded and there is only one Session, one transaction at a time, this process remains extremely simple.

Part 2 of the tutorial adds Person objects that can participate in Events, to display the bi-directional association that can be expressed using JavaBean objects and the Hibernate package. I plan to get through this object-association exercise before the close of business today, posting an update to the files in Subversion at least, and completing the primary tutorial.

Tomorrow's post will explore the basic design of business logic for a persistent Casino world with one or more Blackjack tables, and I hope to add some smarts to the Person object by creating some blackjack Players with the capacity to perform card counting. We will also consider the possibility of a user interface and what bits need expressive elements to make this an interesting simulation. Best of all, I may find my keys before the morning comes!

Tonight, resume the tutorial with 1.3. Part 2 - Mapping associations.