mark's blog

Remote Control The Easy Way

Yesterday I needed to take remote control of a friend's PC over the internet. This can be a bit hairy at the best of times, but when the friend isn't exactly what you would call a power user, it can be nigh-on impossible. Fortunately, I've been a reader of Joel On Software for a while now, and was very interested in their intern project Copilot.

On partitions, boot loaders, and multi-boot woes

I have a rather old laptop which is set up to dual boot between Windows XP and Linux (Red Hat 9) using GRUB. Unfortunately this machine now needs to be fully dedicated to Windows (it only has a 10GB disk, and we have 8GB of data to be cleansed using a Windows app), so I've had to remove Linux. This proved slightly trickier than I suspected, mainly because of my own rashness.

The laptop was configured with four partitions:
1. the main Windows partition (XP was installed before Red Hat)
2. a Linux boot partition
3. a Linux OS partition

Drupal pages sometimes come up blank!

OK - pretty weird problem today. My local dev Drupal site was acting a bit strange. Most page requests worked fine, but some (e.g. /logout) brought back a completely blank page. "View source" on the page showed that the source was completely blank too. No errors in the apache error log, and nothing in the Drupal watchdog table.

New Hosting Provider

Until the end of last week, this blog was hosted on my free web space from my ISP, Freedom2Surf. Now, while these guys have been great as an ISP (good value, uptime and performance, free regrades to higher bandwidth, turning a blind eye to occassional overstepping of my monthly bandwidth allowance!), their free web space is pretty basic. There's PHP and MySQL, and all was fine until I wanted a proper domain name for the site. Having bought a domain name, it seemed there were two options for making that domain name take users to my site:

PHP RSS Parsers

So, the next thing to build in my site is an RSS parser. I'm uploading video files to a hosting provider, who generates their own unique ID for each video. However, when users browse my site they want to play these videos, which means that I need to know the hosting provider's ID for the video the user wants to watch.

My video host provides an RSS feed of my uploaded content, which includes their IDs. So I need a scheduled task which will poll this feed and parse it so the IDs can be written back to my database.

What tokens are available in Drupal?

Drupal has a very powerful module called Tokens, which makes various pieces of data available in other modules. As an example, the Pathauto module will create friendly URLs for any piece of content based on some feature of that content, using token substitution. By default, a new piece of content will be available at the URL http://www.mysite.com/node/5 (assuming you have enabled clean URLs).

Importing Data Into Drupal CCK

I've now got a bunch of structured data in a relational database, and need to get it into Drupal. I've created my content types using CCK. Fortunately, there's a great overview here which highlights some of the core Drupal tables I need to populate which aren't immediately apparent.

Everything is pretty straightforward, apart from populating deltas for repeating fields in CCK.

An example will help here.

Suppose I have a content type of person, who can have multiple phone numbers. CCK lets me add a field of type text, which is defined as a repeating field. To the end user, this looks as though you can simply enter as many phone numbers as you like for this person.

In the database, CCK creates a table called content_type_person, which holds simple fields (i.e. fields where there can only be one value - things like first name, surname). It also creates a separate table for repeating fields, so phone numbers will be stored in content_field_contact_telephone. This new table is keyed on vid and nid (i.e. the current version of the node this person belongs to), and delta. Delta is a zero-based autoincrementing field, which increments for each new value for this nid.

Again, an example will help.

I create a new person, which is internally given nid 1 and vid 1, and added to content-type-person. If I add three phone numbers, these are added to content_field_telephone with nid and vid of 1, and deltas of 0, 1 and 2. A second person with nid 2 would get deltas 0, 1 and 2 again:

nid     vid     delta     phone
1 1 0 01234 567890
1 1 1 01234 567891
1 1 2 01234 567892
2 2 0 01234 567893
2 2 1 01234 567894
2 2 2 01234 567895

I've got hundreds of people, and several phone numbers for each. I can create the content node OK and get the right nid and vid, but how do I then insert all these into the database, and get nice zero-based incrementing delta values?

Drupal Tutorials

I'm starting to get the hang of Drupal now, largely thanks to Robert Safuto's video tutorials (especially the one about CCK and Views) - nice one Robert!

Getting started with Drupal

A few weeks ago, I decided that the best foundation for the site I'm working on would be Drupal. After some discussions around the scale of the site and the likely complexity of our customisations, this seemed to be the natural choice. One of the key factors in this decision was the perceived strength of Drupal's architecture.

Connecting C# to MySQL

My previous lives have left me pretty handy with C#. I only really used .net 1.1 for serious heavy lifting, so I'm finding all kinds of nice suprises (like generics - strongly typed ArrayLists at last!) in .net 3.5 now that I've started using Visual Studio 2008 (and finding that the free Express Edition is fine for commercial development came as a rather nice suprise too!).

One of the big down sides with the whole Microsoft ecosystem is the cost of getting off the ground, so as a startup we are going down a pretty standard open source tool route (i.e. LAMP servers). However, we have some fairly sophisticated spidering to be done to get structured data from a fairly large number of web sites of widely varying quality, so in the interests of getting up and running quickly, I've developed the spider in C# (with a fairly massive leg-up from Jeff Heaton - thanks Jeff!). I need to get the spidered data back into MySQL so that our other applications can use it, which brings me to today's problem.

Syndicate content