November 2006 Archives

Hashes to OpenStruct

|

Ruby continues to impress me. I don't think I've written a Perl script in a year. I really love the way it handles attributes. That's why I've come to appreciate OpenStruct. This handy class allows you to essentially create data structures on the fly.

I've also come to really love YAML as a way to represent data structures. I find it more visually appealing and easier to edit than XML. Since Ruby has a built in YAML parser, this is a match made in heaven. My one beef is that accessing nested data is a bit of a pain. Say, we have the following YAML:

invoice_number: 34843
date: 2001-01-23
products:
  - sku         : BL394D
    quantity    : 4
    description : Basketball
    price       : 450.00
  - sku         : BL4438H
    quantity    : 1
    description : Super Hoop
    price       : 2392.00

Accessing the first product's SKU, requires the following code:

>> invoice = YAML.load_file("invoice.yml")
>> invoice["products"].first["sku"]
=> "BL394D"

Wouldn't it be great if you could access it like:

>> invoice.products.first.sku
=> "BL394D"

Well, now you can. I've created a function called hashes2ostruct that recursively converts all hashes to OpenStructs. As seems to be common with Ruby, it's not a whole of code:

Announcing MAME OS X

|

You may remember from my post about hacking the boot image of Intel Macs that I was interested in doing this for a MAME arcade cabinet. Astute readers will also know that there is currently no Intel port of MAME for OS X. The MacMAME project has been dormant for most of the year, and is PowerPC only. SDLMAME does compile and run fine, but as with most cross-platform projects, there are a couple minor things that would be nicer if it could target OS X only. So, being the freak that I am, I decided to work on my own MAME port to OS X. After a couple months of work in the background, it is finally ready for general release. I am officially annoucing the "MAME OS X" project, so check out the home page for download links to a universal binary.

It definitely has some warts and in need of some spit and polish, but at least it's not embarrasing. All video and sound emulation should be working, and it shouldn't crash. Enjoy, and please report any problems you find on the SourceForge bug page or the web forum. I'll describe some of the behind the scenes tech details in the next few paragraphs.

About this Archive

This page is an archive of entries from November 2006 listed from newest to oldest.

October 2006 is the previous archive.

December 2006 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Links

Powered by Movable Type 4.1