Burning and rebuilding bridges

… of the network kind, of course 😉

This past weekend I decided to take the plunge and start virtualising some of the many things my home server does, such as printing via CUPS, hosting my dev sites and documentation, backing up all computers in the flat and so on. I managed to get 2 Debian Lenny VMs up and running with this tutorial, and all seemed good and well with the world. Well, apart from one thing.

It seemed that the new VMs I had created were unable to see the outside world, and likewise could also not be pinged. The one existing VM used as a Jabber server, however, was working perfectly fine.

This was an immensely frustrating problem, which consumed pretty much all of my weekend with no luck. However, after over 4 days of searching with little luck (and many edits to this post), I finally found a network setup that worked for me. In /etc/xen/xend-config.sxp, I only enabled (network-script network-dummy) and (vif-script vif-bridge), while my /etc/network/interfaces is set up as:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto br0
iface br0 inet static
        address 192.168.1.x
        gateway 192.168.1.1
        network 192.168.1.0     
        netmask 255.255.255.0
        bridge_ports eth0
        bridge_stp on
        bridge_maxwait 0

And each virtual guest having this bridge specified in the networking section of its respective config file:

vif         = [ 'ip=192.168.1.x, bridge=br0' ]

My name is JSON, Part 1

So here it is, my first post. And while I may have been slightly distracted by the rise of our robotic overlords, it didn’t take me that long to think of a starter for 10. As a mobile and web developer there are always certain things that may not seem important at first, but start to take a greater importance when you realise just how useful it can be, even for mundane things like encapsulating data for easy transfer.

So I’m beginning with Javascript Object Notation, or JSON for short. JSON is one of the most widely-used methods of holding data in a structured format, XML being its main rival. This was a topic originally thrust onto me during a University project in 2010, and while seeming daunting at the time turned out to be fairly straightforward. Before I explain how this data can be handled in PHP and Java, let’s take a look at some JSON-encoded data.

So what does JSON look like? Something like this:

{
    "forename" : "Michael",
    "surname" : "Dodd",
    "age" : 23,
    "breaks" : [34, 66, 12, 35, 22, 73, 94, 147],
    "match" : {
        "frames_won" : 5,
        "frames_lost" : 3
    }
}

This example is my performance in a snooker match (I wish!). Similar to PHP, this data structure can be seen as an array with named keys. Each key can contain:

  • A simple value such as a string or integer.
  • An array of simple values, denoted by square brackets [ ].
  • A child JSON object, denoted by curly braces { }.

With the ability to structure data in such a fashion, it is easy to map the data in a JSON object to the data structure in your application. One point to note when creating these structures, however, is to make sure that the final entry in each object does not have a comma at the end of it as this may cause problems with some parsers.

In the next few posts, I will explain how JSON data can be used with PHP and Java (with an Android flavour), but for now check out some of the many potential uses of JSON data with the Guardian Open Platform API.

Welcome

Welcome to my personal website. On it you will find a collection of projects and products I have created, as well as details of my skills and experience in my CV. I also intend to use this blog as a place to discuss various topics and tips from the world of web development and Android development.

So, thanks for visiting, and stick around for more in the future.

Michael