-
Bezurk featured on Channel NewsAsia
The company I work for was featured on a short "Surf Time" segment on Channel NewsAsia's TV channel. Catch the Bezurk Surf Time video on YouTube.
-
How to get strictly valid JSON from Rails
Update: Edge Rails (and the forthcoming Rails 2.0) will emit only valid JSON. Read JSON serialization of ActiveRecord objects reaches maturity for more details.
If you've worked with JSON long enough in Rails, you'd probably have noticed that the JSON the convenient Object#to_json method spits out is not strictly JSON-compliant (according to the RFC 4627, which states that object keys should be "strings", and "strings" should be double-quoted). Here's an example of what
to_jsonproduces when called on an ActiveRecord instance:{ id: 6589, code: "SIN", name: "Singapore", type: "City" }Notice how the keys (id, code, name, type) are not surrounded with double quotes. While this is generally not a problem if working purely in Rails, since Prototype and Rails itself can decode JSON like this, you'd run into problems with more finicky JSON parsers and decoders. PHP's json_decode is a perfect example - it demands that the object keys be double-quoted (or it fails to decode your JSON, silently returning NULL).
For a while I couldn't figure out why Rails was doing it and Google was of no help. I decided to look at the Rails code since this can't be a huge oversight on the Rails community, can it? Sure enough, I found the "solution" in the encoding portion of the ActiveSupport::JSON module:
# When +true+, Hash#to_json will omit quoting string or symbol keys # if the keys are valid JavaScript identifiers. Note that this is # technically improper JSON (all object keys must be quoted), so if # you need strict JSON compliance, set this option to +false+. mattr_accessor :unquote_hash_key_identifiers @@unquote_hash_key_identifiers = trueDoh! All that's left to do is to put
ActiveSupport::JSON.unquote_hash_key_identifiers = falsein yourenvironment.rb(or in the Rails initializers directory if you're on edge) and your Rails app will start producing strictly valid JSON (and is friendlier to other non-Rails applications):{ "id": 6589, "code": "SIN", "name": "Singapore", "type": "City" }unquote_hash_key_identifierswas added in changeset 5486. -
Spam, the Dungeons and Dragons flavor
Now that's how you get a Dungeons and Dragons fan to read your spam:
Laurana's in Qualinesti now, attending the funeral of her father and also trying to arrange an agreement with that stiff-necked brother of hers, Porthios, and the Knights of Solamnia.

-
So I just got back from PLAY! A Video Game Symphony...
I just got back from PLAY! A Video Game Symphony over at The Esplanade Concert Hall (in Singapore) and man, it was good! I had doubts at first about buying the tickets since I didn't play most of the games on their programme, but listening and watching to the gameplay of those games that I did play was pleasantly nostalgic. Here's what was played, with the games that I did play highlighted:
- PLAY! A Video Game Symphony - this is just a fanfare piece composed by the great Nobuo Uematsu (composer of, most notably, many Final Fantasy game soundtracks).
- Super Mario Bros - what a game to open with! Being a fan-favorite, it came as no surprise to hear the collective gasps of recognition in the audience when game footage of the original Super Mario was played on the video screens. A suite of various in-game music was played, each time with much audible amusement from the audience.
- Shenmue and Shenmue II
- Lost Odyssey
- Sonic the Hedgehog - oh man, I didn't realize how much I used to enjoy this game until I recognized every single tune they played in this suite. I played the very first Sonic the Hedgehog on a Sega Mega Drive (as well as a few others after this one - I remember Tails and Knuckles) way back in the day.
- Metal Gear Solid
- Blue Dragon - the much-hyped game had a few pieces of its soundtrack performed. I think I'd have been much more excited if they'd shown some actual game footage instead of scripted cutscenes.
- Kingdom Hearts - a bunch of obvious console gamers near us made loud excited noises when the conductor mentioned this.
- Final Fantasy VI
- Daytona USA - the composer Takenobu Mitsuyoshi performed this piece himself!
- The Elder Scrolls IV: Oblivion
- Chrono Trigger and Chrono Cross
- World of Warcraft - I have the Collector's edition of the original World of Warcraft which contains the game soundtrack (mostly consisting of music composed by Jason Hayes), so these were familiar tunes. My only gripe was that they didn't play the Undercity background music - it's my favorite.
- Halo
- Castlevania - I played the NDS version if that counts for anything. Can't say I recognized the music though.
- The Legend of Zelda - yes, I really didn't play Zelda. I never owned a Nintendo before I got my NDS but I am eagerly anticipating the release of Phantom Hourglass! The conductor was expecting a great cheer from the crowd but it never came heh.
- Final Fantasy VII - for the ending, they played One-Winged Angel from the game soundtrack which was pretty memorable since it was played during the boss fight against Safer Sephiroth and more recently in Final Fantasy VII: Advent Children. A very nice grand ending piece I must say. Still, I do wish they played game footage and more FFVII music than just a single piece. There're so many memorable songs in the game, and the chocobo tunes would have been amusing.

There was also an encore which was very very cool, because the music was from Super Shinobi (also known as The Revenge of the Shinobi). This old Sega Mega Drive game was one of the coolest games of the time (you get to play a ninja!). The composer of the soundtrack, Yuzo Koshiro, was there himself. Super Shinobi's theme music was chosen as the song to play for an encore on Game Axis - I must say, good choice folks! Game footage was played and I recognized every single part of it - I didn't even realize I had memories like that. I'm sorely tempted to see whether my old Sega Mega Drive still works so I can play Super Shinobi again.

After this, the audience demanded another encore and we were rewarded with another rendition of One-Winged Angel (I'd have liked to hear Super Mario Bros again).
All in all, an enjoyable performance - if you're a gamer and missed it, I feel bad for you! If Play! is coming to your location, be sure to get tickets.
-
LOLCATS + email
I IZ BORED: MY LOLEMAIL POST, LET ME SHOW YOU IT.
subscribe via RSS