On a trip to the UK just after Christmas I succumbed to temptation and paid a visit to Toys R Us. Minutes later I walked out with this:

The eee PC

Then I headed straight for my hotel, and once in my room I could barely wait to unpack it. I’d heard it was small, but I was still staggered at just how small and light it is. I switched it on, and it booted in 15 seconds, as advertised. I ran the “First run wizard” and once that was done I clicked on “Wireless networks” and without further ado it picked up the hotel’s WiFi hotspot. Unbelievably simple; I hot-footed it to reception for a card, and within minutes was checking my email.

This is a tiny, cheap sub-notebook that runs Linux and does everything I’m likely to want to do on the move: web, email, word-processing, seamless networking. The interface is a bit Playschool, but that is clearly a deliberate choice; the machine is aimed at the educational market as a cheap, easy-to-use laptop that children can carry around with them. In any case, a browse around one of the burgeoning eee fansites quickly revealed a simple fix to enable “Advanced desktop” mode, which turns out to be exactly the same as my Xandros desktop, so no complaints there. Having said that, 90% of the time I use it in “Easy” mode.

In practice of course, many buyers seem to be geeks delighted to find a cool device that runs Linux and can be hacked to do all sorts of useful things. The result is an increasing number of sites dedicated to the eee and detailing various hacks and improvements. Always a good sign when a community builds up round something like this.

Edit: interestingly, the Xandros website states:

The Eee PC is an ASUS product and is solely supported by them, including Operating system issues. The Operating System on the Eee PC is not a Xandros Product. While Xandros may have aided in the development of the Eee PC OS, it is owned and supported by ASUS.

… but the Advanced Destop mode looks indistinguishable from Xandros.

This device really suggests that the operating system is becoming an irrelevance as long as you have network connectivity. Many users of the eee PC will not know or care what the operating system is; they’ll just use it to accomplish tasks. Microsoft must be a wee bit worried, because the eee has just launched in Japan with Windows XP pre-installed (the original model comes with instructions for installing XP, but you need a valid installation disk and another PC with a CD drive to do so). I don’t really understand why anyone would want to; as delivered the machine only has 512Mb of RAM, and runs very nicely with Linux, whereas if you want anything like acceptable performance with XP you are going to have to void the warranty by installing more memory.

But some people seem to think they should be able to do everything they could do on a heavy, bulky, 15″ notebook PC on this. It’s only got a 7″ screen for heaven’s sake; what on earth is the point of trying to run Photoshop on it? For me its role is definitely that of a supplementary PC, not a desktop replacement. It’s a huge improvement on the slow, clunky Dell laptop we lug around whenever we travel. The 15-second boot time is particularly appreciated; it means you can quickly switch it on to check something, then switch it off again to conserve the battery (battery life without wifi switched on is about three hours; slightly disappointing but over twice as long as the Dell manages). Resuming from sleep mode is even faster. Plenty of thought has been put into keeping the weight down; it also has a relatively small power adapter, similar to a mobile phone one, not the “brick” you usually get with laptops. And it’s surprisingly robust; you’d expect something as cheap as this to feel flimsy, but it doesn’t.

The one thing I don’t like about it is the small trackpad and very stiff mouse button. I don’t like trackpads much anyway, and even increasing the sensitivity doesn’t seem to help. It feels as if it’s going to be the first thing to break. Using a mouse or trackball that weighs half as much as the PC doesn’t seem to make sense, so I’ve ordered a dinky little Targus mouse for it.

We built Corbières Web almost exactly ten years ago, when we first moved to France. The primary aim was to have a site we could put in the portfolio of our budding web development company. We had a wonderful time travelling around the area taking hundreds of photos and discovering all sorts of out-of-the-way places. And we landed our first large contract as a direct result of someone seeing Corbières Web. As the first website dedicated to the area, it built up a fair amount of traffic and even won an award from the Comité Régional de Tourisme. So it certainly wasn’t a waste of time.

Then we got busy and the site got pushed so far away from the stove it wasn’t even anywhere near the back burner. I added links to it occasionally, when people emailed me and asked, and we added a few pages to it for local businesses, for a small charge. But the last time the design was touched was in 1999, and it was beginning to look a bit embarrassing. It wasn’t just the surface appearance that was old-fashioned; the code was a mess of font tags, nested tables, and invalid HTML. And this mass of 150 or so static pages was time-consuming to update, so it just didn’t get done.

I started converting it to use a CMS about a year ago in order to make updates easier, but once again didn’t have the time to complete the job. But then thanks to an online CSS workshop class he was taking, Steve picked it up as a challenge for his final project. The old design was completely scrapped and he came up with a classy new design that is valid XHTML Strict. We merged this with my work on the CMS and were able to launch the converted site within a week.

One of the challenges of the site was that it is bilingual English-French, and each page linked to its equivalent in the other language. Using SPIP for the content management means that you can easily link different language versions of the same content so that links to translations appear automatically, and when visitors choose which language they want to view the site in, that choice is automatically retained. This is the third SPIP site we’ve done, and the more I use SPIP the more impressed I am with it. Its syntax for “squelettes” (templates) and “boucles” (loops) takes a bit of getting used to, but it’s very powerful and I haven’t yet found anything I couldn’t do — even if some things require a fair amount of fiddling to get right. The documentation is superb, some of the best I’ve seen for an open-source web application, and spip-contrib is a good source of extra tips.

It’s always a real headache manipulating dates between PHP and MySQL, because PHP’s date functions assume Unix timestamps, while MySQL has its own internal date format. They both have excellent built-in functions for handling dates, but they are fundamentally incompatible. I’ve torn my hair out before now trying to manipulate dates between the two, because pretty well every application I write needs to do date arithmetic.

Well, duh, I don’t know why I didn’t think of this before, but MySQL has a UNIX_TIMESTAMP function which sorts it all out for you by converting a MySQL date to a timestamp. Simon Willison explains it, so I don’t need to. So easy when you know how!

About the only reason I ever boot into Windows on the spare PC nowadays is because I need to use Enterprise Manager or Query Analyser to manage a SQL Server database. Today it was inconvenient to reboot, because I was in the middle of doing a lot of printing. So I googled “Linux SQL Server client” and came across sqsh. Installation and set up sounded a wee bit complicated (required compiling from source), but doable, so I put it on … the back burner, with a reminder to myself to do it sometime over the next week or so.

Then later on I happened to be sitting at the Mepis PC, so I pulled up Synaptic and typed sqsh into the search field. Hey presto! Two clicks and it was installed. “Still,” I thought, “I’m bound to have to fiddle about configuring it.”

Undeterred, I typed
sqsh -Umyusername -Pmypassword -Smyservername
at the shell prompt, and a sqsh prompt appeared. If Linux doesn’t give you an error message then nothing has gone wrong. So:
use mydatabasename
go

Still no error!
SELECT * FROM mylittletable
and there were the results! Fantastic — if possibly not all that secure when used remotely :-) Highly recommended if you need occasional access to a SQL Server or Sybase database from Linux.

Want to add one (or more) days to a date in PHP? Timestamps are simply numbers of seconds, so it seems so easy and obvious to do this:
$mydate = (60*60*24)+$mydate;
or even just
$mydate = 86400+$mydate;
Don’t be tempted! Twice a year, because of daylight saving, the day doesn’t have 24 hours in it; it has 23 (spring) or 25 (autumn). So all of a sudden you are likely to find your code behaving in a manner which is downright weird. Been there, done that. The approved way is just as simple and far less likely to result in hair-tearing:
$mydate = strtotime("+1 day", $mydate);

Edit: here’s a function for calculating differences between times. Untested for resistance to DST, but could be useful in some situations. Ironically, the post he links to about calculating date difference more precisely in PHP (also untested) looks as if it does not take this problem into account. Go figure :-)

The scenario: a mixed network of Windows and Linux PCs (2 Windows XP, one Xandros, one SimplyMEPIS) which need access to edit files in a directory on one of the Linux servers. Here’s what I did: I’m not sure all the steps were necessary, but none of them is sufficient on its own!

It is taken as read that the PCs are all in the same workgroup, and Samba is installed and running on the Linux PC with the files to be shared.

1. Create users with the same name and password on all the PCs. Create a group on the Linux PCs and add the users to it (in this example the group is called editors). Note, the numeric user and group ids on the Linux boxes must be the same. If you are using a GUI interface to create users and groups, check the numbers they end up with. If they are not the same you need to use e.g.
groupmod -g 1002 editors
to change one of them to match the other. This might invalidate the group of any files belonging to users in that group, so check and reset the group if necessary, using chgrp:
chgrp -R editors www

You can make editors the default group for the users if you like, but it’s not necessary.

2. Create the directory to be shared (www in this example); it should be owned by one of the users created earlier and have the group set to editors. Use chmod to make it writable by owner and group. Now, set the sticky bit to force files to inherit the group permissions:
chmod g+s www

3. You can edit /etc/profile.d/profile (as root; the exact path of this file may vary) and change the umask line to read
umask 002

This globally forces new files to be created with group write permissions.

The steps so far have ensured that users in the editors group on the Linux box can edit files in the www directory and its subdirectories. Now you need to share the directory using Samba. Use a GUI tool if you like to set up the share (SimplyMEPIS has a nice one). But ultimately you will need to edit /etc/samba/smb.conf (as root of course) to make sure it’s set up correctly. This file is not difficult to understand, but make a backup copy first in case you trash anything. The minimum needed is the following:

4. In the [global] section, under authentication, set
security = share
This is not the most secure way, but it’s OK on a suitably small and private network. I tried using security = users, but the Xandros PC didn’t seem to like this at all; the file manager hung on opening when any of the shares were mounted.

5. In the section for the www share, force the user to be one of the users you set up earlier:

[www]
public=yes
browseable=yes
path=/opt/www
writeable=yes
force user=veronica

You might have other stuff in there, but I think this is the minimum (it was the “force user” that finally got it to work for me). If you want you can restrict access by IP address to make it more secure, e.g.:
hosts allow = 192.168.1.0/24

Don’t forget to stop and restart Samba if you have edited the smb.conf file! As root:
/etc/init.d/samba restart

6. Test by mounting the share on another PC and creating, editing, or deleting a file on the share.

I have been looking for a while for a tool to create Entity Relationship Diagrams (ERDs) on Linux. On Windows I used Dezign for Databases, an excellent tool which I would still be using if it was available for Linux. Linux tools that do as much as it does are few and far between. DBDesigner4 is open-source but wouldn’t run at all on my system and doesn’t seem to have any visible means of support. After much searching I ended up evaluating a commercial (i.e. non-free) product, Data Architect, from theKompany. After a few false starts trying to install the demo from an RPM, I managed to get it to work by the simple expedient of downloading and unzipping the tar archive. I had to edit the shell script to replace ksh with bash, but then it worked.

However, it requires ODBC to talk to databases (not an essential feature if you are just doing design amd then generating the necessary SQL scripts, but definitely nice to have). Being a Microsoft invention, ODBC is not that easy to get working on Linux. It took me all morning, but I succeeded in the end. So here’s how to do it on Xandros Home Premium:

1) Use Xandros Networks to search for and install unixODBC, the package that provides ODBC support (or use apt-get, or whatever package manager you use, or download direct from unixodbc.org).
2) As far as I could tell this did not install the GUI front-end that allows you to manage ODBC data sources in a similar way to the ODBC manager on Windows. This is not essential because you can simply edit the relevant configuration files if you know what you are doing. Not knowing this, I visited unixodbc.org and downloaded unixODBC-gui-qt-2.2.11-1.i386.rpm, which I then installed using Xandros networks.
3) Great, ODBC support is now available and the GUI works! However, I don’t have any drivers. I want to use it with MySQL, so it’s off to MySQL to download the necessary driver. Again I downloaded an RPM and installed using Xandros networks. I quickly found that this didn’t work with Xandros. So a quick Google sent me off here for a Debian package. Goodness knows why MySQL don’t provide a Debian version.
4) Now I again ran the GUI front end installed in step 2, and hey presto, the driver was there. The bad news: when I tried to set up and connect to a data source I got a message saying that the driver couldn’t find /var/mysqld/mysqld.sock. Not surprising, since this file did not exist. More googling and a poke around my file system established that the file was actually at /opt/lampp/var/mysql/mysql.sock. 5) So I needed to edit the odbc.ini file to tell it where to find the socket:

[MySQL-test]
Description = MySQL database test
Driver = MySQL
Server = localhost
Database = test
Port = 3306
Socket = /opt/lampp/var/mysql/mysql.sock
Option =
Stmt =

Progress! Now I can connect, but when I try to authenticate with a username and password, “Client does not support authentication protocol requested by server; consider upgrading MySQL client.” Aha, I’ve encountered this before; it’s to do with the password hashing in newer versions of MySQL being incompatible with clients expecting older version. So, simple solution:
6) Set up a user for ODBC purposes, with the appropriate privileges, and issue the command:

SET PASSWORD FOR odbcuser@localhost = OLD_PASSWORD('mypassword');

7) Try again, and yes, I can browse the databases and tables now! Nice added bonus: ODBC is also available in OpenOffice, so I can access my databases from there too. Let’s just hope that DataArchitect does the job …

Scriptaculous is one of the better-known Javascript/AJAX libraries, with useful built-in objects for adding Web 2.0 functionality to your pages. I’ve tinkered with it but hadn’t found a real-life application for it until I needed to allow a client to reorder a grid of thumbnail photos by dragging and dropping them. Added complication: she uses Safari.

Oh how I hate coding Javascript! I got something kind-of working, including an Ajax callback to update the database, but it wasn’t very satisfactory. So I put it aside for a while and looked at it again when I had some spare time. This time I came across Greg Neustaetter’s PHP wrapper class for Scriptaculous lists. Aha, the power of Scriptaculous without the pain of Javascript! With the aid of his well-documented examples it only took me about half an hour to create a proof-of-concept. So Web 2.0 here I come …

A handy reminder today of the incredible potential for both bad and good represented by the Internet.

The good:
ConceptShare, a new online collaboration tool for graphic designers to work collaboratively, viewing and marking up designs online. A rare example of excellent use of Flash to do something genuinely useful.

The bad:
Stanford University says that if we were designing the Internet today we wouldn’t start from here.

We believe that the current Internet has significant deficiencies that need to be solved before it can become a unified global communication infrastructure. Further, we believe the Internet’s shortcomings will not be resolved by the conventional incremental and ‘backward-compatible’ style of academic and industrial networking research.

The ugly: new exploits using Javascript inserted on unsuspecting third-party websites to at best show unsolicited adverts and at worst download and install malware on Windows computers. An interesting post from Ethan Zuckerman explains, and proves the point that if you accept input from users and display it on your website for others to see, you should filter it for unwanted HTML and script tags first! Interesting that Google is now detecting these exploits and warning site visitors.

Hat-tip for pointers to all of these to John Naughton’s eclectic Memex.

The change of software in my last post meant that not only the domain, but all the page names and the entire structure of my recipe site changed — a big no-no for search engine purposes! On the other hand, the traffic this application gets isn’t actually worth anything to me in monetary terms — quite the opposite, it just uses bandwidth ;-) — so I wasn’t hugely bothered if it lost rank in Google for a while. In fact it was a golden opportunity to test the best way of handling this situation.

I started off by buying a brand new domain name, setting up MovableType, importing all the data, fixing up the design, and testing it to see that it all worked OK. At this stage it was a secret from Google. Once I was happy, I wondered just how I was going to keep all that precious traffic to the old site. I didn’t want to devote a huge amount of time to it, so I decided I’d just use 301 redirects (this is a header sent by the web server that tells the page requester that the page has “moved permanently”; there is also a “temporary redirect” status).

Thank goodness for dynamic pages! The old system used a single page called ShowRecipe.asp which took the id of the recipe and displayed it. So I just recoded this page to take the id, look up the recipe title, and convert it into the new URL (MovableType uses “search-friendly” URLs constructed from the recipe title). Then it does a 301 redirect to the URL on the new site. I removed / renamed the few other pages on the old site.

I added the new site to my Google webmaster tools page and monitored the results. Google came and spidered a few pages from the site within a couple of days, and I was soon seeing almost the level of traffic I’d had on the old site. Within a week there were 23 pages in Google’s index, which seemed not bad for a brand-new domain registered less than a fortnight before and with no incoming links yet, apart from our own site. As of now, Google has spidered again and picked up over 140 pages.

The process is evidently not finished yet though, as old redirected pages are still showing high up in Google (#6 for “pitta bread recipe” for example). Of course if anyone clicks on those results, they will automatically end up on the new site anyway, because of the redirect.

I’m probably not going to bother going after links to the old site and asking people to change them, but I would if this was a commercial site. Otherwise old linked-to pages seem to hang around in Google forever.

So at present just doing the 301 redirect looks as if it is going to work pretty well. If you completely change the structure of your site it’s well worth doing a specific 301 redirect for every page I think, for the benefit of human visitors rather than search engines.

« Previous PageNext Page »