June 26th, 2007
I had to spend some time setting up Xen on one of the new Dell servers we bought and while there was some documentation around, I had to constantly refer to the different sources since there wasn’t a complete page which had everything I needed for my particular situation - I have a host machine with Ubuntu Feisty Fawn installed and wanted to install a couple of Xen guest domains on it. One other thing I found lacking in the documentation is the explanation of commands or answers to the question “so why the hell am I doing this?”. I’m not considering LVM at the moment and am happy with loopback disk file images too.
So I think it’s a good idea to write this down somewhere for the next time I have to do the same bloody thing over again on any new servers.
Some caveats before we start:
- Like I said, I’m not gonna talk about LVM for disk images since I know next to nothing about configuring it at the moment. The host machine I have isn’t setup with LVM and I haven’t got the time to look into LVM either.
- I’m quite the networking newbie, so my setup uses the default Xen bridge installed via apt-get. Check out Xen networking on the Xen wiki for more complex network setups.
- I’m not gonna talk about putting a Linux distro other than that of the host machine into the Xen virtual machines. In other words, I have Feisty Fawn for both dom0 and all my domUs.
- I probably did some completely stupid things. Stuff like xen-tools exist to simplify Xen administration, but I haven’t had a chance to use them. Let me know if you spot an error or have a better way of doing something please!
Some terms that deserve explaining (most guides out there just use “DomU” and “Dom0″ without any ceremony, and assume you know what they mean):
- Domain-0 or Dom0: This refers to the host machine OS. You know, the OS of the actual physical server that you have.
- DomU: This refers to a Xen guest domain. A DomU is a single Xen virtual machine. The “U” stands for “unprivileged” I believe.
OK let’s go!
Read the rest of this entry »
Read the bug fix announcement. Upgrade! This was causing extremely puzzling crashes in Safari on Macs (pre-Safari 3 beta) on one of our applications and I’m glad (in some ways) that the problem lay with the Prototype library. (2)
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. (1)
June 20th, 2007
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_json produces 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 = true
Doh! All that’s left to do is to put ActiveSupport::JSON.unquote_hash_key_identifiers = false in your environment.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_identifiers was added in changeset 5486.
June 18th, 2007
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.