Blog

Adventures With Tonic Water

Some people from work invited me to the Dominion Tavern a week or two ago. I was persuaded to try the gin and tonic, as I was told that the tonic water was homemade.

I ordered one. The drink that came was orange in colour and looked vaguely like tang. In other words, it did not look like a gin and tonic. It tasted, however, unmistakeably like a gin and tonic - a rather good gin and tonic at that, and this comes from a guy who's not particularly enthusiastic about gin and tonics.

I was inspired to try this out myself. The active ingredient in tonic water, giving it its characteristic bitter taste, is a substance called quinine. Back in the day, quinine was used as a painkiller and malarial treatment. In the (rather large) quantities required for medicinal purposes, it was known for its strong, unpleasant bitterness, so people started mixing it with gin to make it more palatable. As time wore on people started consuming quinine less and less as a medicine and more and more as a flavouring agent, especially in the quantities used for modern day tonic water, which is many times less than required to receive any therapeutic benefit (you'd have to drink something like 8L of modern day tonic water to approach even just one dose of malarial treatment).

Read more

Comments and Trackbacks Have Been Deactivated

When I started this blog, I didn't expect very much in the way of comments or trackbacks. I also didn't expect any spam, which means I didn't take any precautions. I mean, how would anybody even know about this blog?

Silly, silly me.

So, I have turned off comments and trackbacks until I figure out a reasonably reliable way of separating the spam from the ham. This will probably entail a bit of a rewrite of YAWT as I figure out a way to do this in a clean and modular manner. Why make it easy on myself when I can make it hard?

Read more

Error Handling in Perl

Okay, this won't be the most exciting entry in the world. There are several different ways of logging or recording errors and warnings in perl, and I find I easily get confused. So this entry will serve as a very, very basic reference for me. Other people may find it useful. Or not.

Core Perl

die LIST

Taken from the Perl 5.10.0 documentation:

Outside an eval, prints the value of LIST to STDERR and exits with the current value of $! (errno). If $! is 0 , exits with the value of ($?>> 8) (backtick command status). If ($?>> 8) is 0, exits with 255. Inside an eval(), the error message is stuffed into $@ and the eval is terminated with the undefined value. This makes die the way to raise an exception.

Read more

French as an Emergent Property

In a previous blog entry, I described various solar system simulations I played around with in high school. These were perhaps more properly termed "gravity simulations" since what I simulated was not a solar system per se but rather Newton's laws of gravity and motion as applied to a bunch of swirling rocks, which would produce a solar system if the conditions were set up correctly. The orbits that you saw in these programs appeared naturally out of the math, as emergent properties of the equations - they were not explicitly programmed.

This is a key feature of the simulation; I did not start out by assuming that the orbit would be an ellipse, or that there would even be an orbit at all. Rather, I started from the basics: the laws of gravity and motion, and saw what came out of them.

Read more

New Blog

So I got myself a new weblog, hosted on Netfirms. I'm not particularly enjoying the Netfirms experience, but it was only $10 for a year and I get SSH access. They're quite skimpy with the perl modules, forcing me to install a bunch of stuff in my home directory.

I'm using a homemade blogging program because I got tired of blosxom's ugliness and I didn't really like what I saw of Bryar. I'm calling it YAWT in my head - short for Yet Another Weblog Tool. I'm hoping to extend it at some point to handle photo galleries in a seamless and efficient manner - my last attempt to write an online photo manager was quite slow. We'll see.

Read more

Why Watching "Buffy the Vampire Slayer" Is Not a Waste of Time

I've been recently spending a significant amount of my free time watching "Buffy the Vampire Slayer" and "Angel" on DVD. I never watched them when they were on the air, but now I'm catching up.

This has earned me accusations of being hypocritical, since I apparently tend to be critical of people who spend (what I consider to be) too much time watching TV.

Well...yes and no. I don't think I'm critical of people who spend a lot of time watching TV. How could I be? I watch a lot of TV myself. I am, on the other hand, critical of people who spend a lot of time channel surfing.

Read more

Scoping in Perl

I just read a very clear tutorial on Perl scoping mechanisms:

http://perl.plover.com/FAQs/Namespaces.html

I often get bitten by scoping issues but unfortunately (or fortunately?) it's usually easier in Perl to work around your problem than to understand the reasons behind it.

One part I found interesting was the section labelled "The Current Package" which explains the use of the package command in Perl. There is a tendency (or, at least, I have a tendency) to conflate the use of the Perl package command and, say, the use of the Java package declaration because they are often used to achieve the same effect, namely the separation of namespaces, and also because, by convention, they are used in a syntactically similar way. Because of this, it is easy to forget that the package command in Perl is just that: a command. You can call it from anywhere, multiple time from the same file even, and the effect is simply to change the current package - which in itself doesn't have a huge effect on how you write your code, just the way to access your variables.

Read more

Solar System Simulations

When I was in high school, I used to program two dimensional solar system simulations for fun (as you can surely tell, I was extremely popular and desired by all the ladies far and wide). I would put a "sun" in the middle of the screen and I'd spin "planets" around in simulated orbits.

There are essentially two ways you can go about programming solar system simulations. Technique 1, which for lack of a better term I will call the explicit technique, means deciding (or realizing) at the outset that the orbits of your planets will be elliptical, and then writing your program based on that. The explicit technique works because there are certain exploitable patterns in elliptical planetary orbits that can be harnessed to great advantage. Planets move faster when they are closer to the sun, for example, and slower when they are further away, in mathematically determined ways. One can derive formulae for the position of the planet on the orbit versus time.

Read more

Let It Snow

Cheesy title, I'm aware, but Montreal just got something like 30-60 cm of snow, depending on which weather report you read, and it's gorgeous.

I live on the 26th floor of my apartment building and from up there it's a bit difficult to see just how much snow we got. I get to the street level this morning and I see snow banks higher than my waist. I don't remember having this much snow since I was in primary school, and I was smaller then so my memories might be playing tricks on me.

I'm sure there's a lesson in all of this about global warming (why is it that I can't recall snowbanks this high in such a long time?), but for the moment it's nice. We might just get a white Christmas this year.

Read more