Advice needed: Stylesheet background not displaying properly

December 23, 2003

Much as I like to solve such problems myself, I thought I'd ask the question because I personally don't know the answer:

While the front page looks fine, when you hit the archives on this site (try clicking on the time the article was published), and view them with internet explorer, the background gets all screwed up - it doesn't appear right and when you scroll up or down it just gets worse. Gaps appear in the background, text goes missing and only reappears when highlighted and generally there's something just wrong with the way the stylesheet formats the page - anyone know what to do about this? Answers on a postcard either in the comments section (which also fails to appear correctly much of the time) or to admin@salocin..com (remove extra dot).

Posted by nlvp at 06:21 AM | Comments (0)

Belgian scientists make anti-bubbles in beer.

Posted by nlvp at 05:41 AM | Comments (0)

Multiple table UPDATE query in MySQL

December 13, 2003

How do I update a table using one or more other tables in MySQL? The solution is simple, but if you're trying to do it with an UPDATE statement in MySQL versions lower than 4, you're likely to be quite frustrated.

I was recently trying to figure out a way of updating a table in MySQL using a relationship with another table. It turns out that in MySQL versions below 4, it is impossible to reference other tables in an UPDATE statement. This is a problem, and although it’s easily circumvented, I thought I’d write up how it’s done, because two people I’ve spoken to didn’t know.

Here is the problem I faced: I have a table full of order data (OrderTable), with unique IDs for each row. I have a second table (TimeData) which contains information regarding the time and date at which the orders were made, and has the same unique IDs, and I want to insert the data from that table into the original order table, obviously matching the IDs up so that the right order receives the right time. An additional complication is that TimeData does not contain a record for every single record in OrderTable.

TimeData contains two rows : id (INT NOT NULL), and ordertime (DATETIME).

We can see what the final table ought to look like by building it with a SELECT statement :

SELECT OrderTable.*,TimeData.ordertime from OrderTable LEFT OUTER JOIN TimeData ON OrderTable.id=TimeData.id


But what we really want to do is to add the TimeData.ordertime column to OrderTable.

What you might have already tried, which doesn’t work, is the following :

ALTER TABLE OrderTable ADD ordertime DATETIME

UPDATE OrderTable SET ordertime = TimeData.ordertime where OrderTable.id=TimeData.id


The reason this doesn’t work is that UPDATE only takes inputs (in MySQL Versions < 4) from a single table, and is therefore unable (in my experience) to grab data from the TimeData table. The way around this is to create a new table, built from a SELECT statement, as follows :

CREATE TABLE NewOrderTable SELECT OrderTable.*, TimeData.ordertime FROM OrderTable LEFT OUTER JOIN TimeData ON OrderTable.id = TimeData.id


Here’s a brief breakdown of the syntax :

CREATE TABLE NewOrderTable SELECT ...
This creates the new table, and indicates that it will be built from a query.

... OrderTable.* ...
This pulls in the entirety of OrderTable

... ,TimeData.ordertime ...
This pulls in the additional column from TimeData

... FROM OrderTable LEFT OUTER JOIN TimeData ...
This tells us which tables we want, and the type of relationship we want to create between them. A left outer join means we want to pull in all of the rows from the table on the left of the query, and only those rows that have a related record from the table on the right. The reason we need this type of query is to ensure that we pull in every single column from OrderTable. If we just had the two tables listed and a relationship based on the IDs, we would end up with only those rows that were represented in both tables.

... ON OrderTable.id=TimeData.id ...
This tells MySQL what the specific relationship constraint on the two tables is – in this case, rows in TimeData and OrderTable that have the same value in the id field should form part of the same reported row, and will therefore be part of the same row in the new table we are building.

Now all that remains is to rename the old table (OrderTable) to something else, and then replace it by renaming the new table (NewOrderTable) to OrderTable. Keep a copy of the old table so that if anything went wrong, you can reverse the process without losing any data.

This is a very (very) simple application of MySQL commands, but worth examining because they solve a specific problem that often crops up, and because they demonstrate a specific case of certain commands –

  • How to use CREATE TABLE to build a new table based on the content of old tables.
  • How to use the LEFT OUTER JOIN relation, and how it works.
  • How to get around the single table limit in the UPDATE statement in MySQL versions lower than 4 (most MySQL servers that I run across run 3.x.x).

Hope this was helpful, please let me know below if this helped you or if you have additional questions.

Posted by nlvp at 02:21 PM | Comments (4)

Bruce Almighty

December 12, 2003

brucealmighty.jpgBruce Almighty is the latest vehicle for Jim Carrey. Much like The Truman Show, this novel comedy manages to pack an elegant comment on life. In this case, the nature of what makes us happy.

Bruce Nolan is a TV reporter. Because of his instinctive hilarity, he is constantly assigned the kooky and weird stuff to report on, and it frustrates him not to be taken seriously. Over a period of time, he experiences more bad luck than is common, and he soon sees every little problem that befalls him as a sign that God either hates him, or is asleep on the job. Unable to blame any person for his bad luck, he turns on God, and screams to the heavens in frustration - several times.

So God, played by a white-clad Morgan Freeman, decides to give him a chance to set things right. Endowed with God's power, Bruce is asked to run the world, and in the process learn his lesson. Interactions with his girlfriend (Jennifer Aniston) take on an interesting new twist, and he sets about righting the wrongs he feels have befallen him, before realizing that divine powers aren't exactly making him happy, and perhaps he misdiagnosedd his problem in the first place.

This is Jim Carrey trying to draw a balance between his fantastic ability to perform physical comedy, and a desire to imbue the role and the movie with more than just laughs. He succeeds quite well in all but a couple of instances, and provides his fair share of laughs while managing to keep the ending emotional and significant, rather than just resorting to a final joke. Much of the credit must go to the scriptwriters, who managed to tie a good idea to some fine, tight sequences.

Although much of the world dislikes Jim Carrey, this is more due to an overassociation with roles in movies such as Dumb and Dumber or The Cable Guy, where he deliberately overplays an inherently dysfunctional character. His ability to generate more profound emotions is often overlooked, but has been demonstrated in several of his movies. We caught the first glimpse of it in a few scenes in The Mask and it was clearly much more developed by the time he got around to Liar Liar, The Truman Show and Bruce Almighty.

A good movie, fun to watch, well acted and well made.

Posted by nlvp at 11:29 AM | Comments (0)

Windtalkers

December 11, 2003

windtalkers.jpgJohn Woo forays into US military history with a film about the capture of the island of Saipan, and the role played by the Navajo code in the co-ordination of army, naval and military units during combat.

Sgts. Joe Enders and Ox Henderson, played by Nicholas Cage and Christian Slater are assigned to follow "CodeTalkers", Navajo indians who have been taught a code based on their own language that allows the US forces to communicate in ways indecipherable to the enemy. Their assignment is to protect the Code at all costs, if the enemy learns how to decipher the code, then a critical advantage will have been lost.

Given the implications of these instructions, and for other reasons besides, Sgt. Enders seeks to minimise the friendship and camaraderie that develops between him and his assigned CodeTalker, all the while seeking to get over the devastating loss of his entire previous unit; something which he feels he must bear some responsibility for.

The development of the relationships between the characters are quite well drawn - they are the meat of the film and are thankfully not too rushed or crude. The plot itself, however, leaves very little room for surprise, and events conspire to develop a story that suffers from being far too predictable. It is fairly clear from early on who will live and who will die, who will be transformed by war and who will ultimately be redeemed. As these obvious plot developments approach, and we see them coming, there is that all-too-familiar desire to fast-forward past the next bit to see if the scriptwriters managed to find something original to do immediately after the predictable material.

As a story of the heroism of the CodeTalkers, it fails - but only because it succeeds in painting a sufficiently personal picture of Private Ben Yahzee (played by Adam Beach) that it becomes hard to see him as a representative of all the CodeTalkers in the army.

Graphically violent, and with the same levels of death as the Normandy Landing in Saving Private Ryan, this movie fails to live up to the promise implied by the casting of Nick Cage, largely because the writers failed to move away from the tired clichés of war, and instead gave us things we have all seen before. The introduction of the CodeTalkers into the story is insufficient a variation to see this as anything more than another addition to the "War Movies" shelf, and an average one at that. Fine for a quiet night, but don't expect groundbreaking stuff here.

Posted by nlvp at 02:35 PM | Comments (0)

Hearts in Atlantis

December 08, 2003

heartsinatlantis.jpgBased on a Stephen King novel, and set in the 1960s, Hearts in Atlantis paints a detailed portrait of a young boy, Bobby, whose life revolves around his two best friends, Carol and Sully, and his slightly strained relationship with his mother, who is too distracted to properly care for him, and struggling under the financial strain of raising a boy without his deceased father to help.

The setting is painstakingly reconstructed, with all the relevant paraphernalia of the time, including the classic radios, baseball items, architecture and vivid colour that films of the period tend to employ. The discreet, seedy underside of the local populace is also present, and we are made aware of it through inferences we can make about his mother. He remains aware only of the extent to which she has little money and time to lavish on him.

Into this world steps Ted Brauntigan, played masterfully by Anthony Hopkins. Ted is a loner, who arrives with a very few possessions carried in a couple of suitcases and some paper bags. Bobby’s mother distrusts him immediately, but he inevitable steps into the gap left by Bobby’s deceased father, giving the boy advice and insight on life that can only come from the vantage point of adulthood. He gives the boy a job, reading the paper to him every day, in return for the small amount of money that will allow Bobby to eventually buy the bicycle of his dreams. The real reason for his interaction with Bobby, however, is to ask the boy to watch for The Low Men, suspiciously anonymous, secret-service-like individuals who are seeking to track him down because, in his own words, “I have something that they want”.

It takes little time to realize that Ted has a gift that allows him to see partly into the future, and to see into the minds of others, and it is this gift that drives him away from others. This is hardly the point of the story though, and serves mostly as a pivot upon which to turn a plot more focused on the building of father-son relationships, the passage of a boy into adulthood, and the bittersweet nature of the memory of childhood. While the film leaves us with a slightly melancholy feeling, the overall effect is of a role in the lives of others that all people have, and that that role, while perhaps not central to our own lives, can be of great value or can cause great distress in the lives of others. Although you will not finish the story laughing for joy, I think that in ways somewhat more meaningful, stories such as this want to make us think about the importance of our actions and thoughts on the lives of those around us.

Well crafted and well acted, this drama has every right to claim two hours of your time, even if it was always unlikely to break box-office records or headline award ceremonies.

Posted by nlvp at 04:13 PM | Comments (0)

PC Crash for 2003

December 03, 2003

Once a year I suffer a complete system failure, and my computer goes totally bonkers. Last year it was the hard disk that gave me the terrible UNMOUNTABLE_BOOT_VOLUME error, this year it's something a little more confusing, but nonetheless a pain in the posterior for a day or two...

Last year, it hit me in the middle of October. First year finals week. Now that I'm in the second year of Wharton, finals week is in early December. So guess when my computer decided to go on a mental vacation?

Anyway. It was one of those strange and unexplainable problems, where everything gradually begins to not work. First it's the HotSync program giving port errors, then it's the network connections crashing their respective services, then it's the Infrared port giving me lots of errors despite the fact that there isn't an infrared beam for a hundred miles. Soon enough you're spending more time closing error windows than doing any work, and you can't get the applications with which you work to start anyway, so before your CD writer joins the picket line, you copy everything you can think of onto a couple of CDs and hit the IBM factory reset option at bootup.

You'd think that would solve the problem, but you're really just exchanging a large but uncertain amount of pain for a large but completely certain amount of pain. 8 hours later, I was beginning to get my system operational again, had reinstalled XP and Office and the Printer and Verizon and the option pricing software and Crystal Ball and so on. Then I connect to the internet to download my school's version of Symantec antivirus, ZoneAlarm and the Windows Updates, but within 5 minutes of connecting, a virus (Worm_Agobot.R) slips in on port 135, installs itself and starts selectively shutting down processes and screwing with the newly installed Symantec anti-virus program (it shuts it down at 15 second intervals so it never gets a chance to detect it).

So a long protracted fight begins between me and the virus as I load regedit, try to track down the key that's loading it at startup, but keep getting regedit shut down on me every 15 seconds. It's a slow process. It takes an hour and a half. The long and short of it is, if your anti-virus spontaneously and randomly shuts down and you're having problems with the system shutting itself down periodically (NT/ADMINISTRATOR) because SVCHOST has crashed, or the RPC (Remote Procedure Call) has been shut down, then check your task list for svchos1 because that's the blighter right there. He's a pain to get rid of too.

Anyway - finally re-installed, having to go through all of those annoying first-time ZoneAlarm connection messages (MAD.exe, the Motive Chorus Daemon, for example - a benign information servlet that sends data on my connection back to the Verizon helpdesk, but has a name that proves programmers still play DnD) and on the bright side, my sleepless night has provided me with a computer that now runs twice as fast as it used to. For the next 3 days at least, I'm installing the 41 (!) XP patches as we speak (so to speak).

Posted by nlvp at 05:36 PM | Comments (0)