Friday, December 15, 2006

Tinkering with iLike

I've decided to give iLike a whirl. So far, it seems alright. However, I'm not convinced that it's as interesting as MOG or the Filter, but, the real time reporting it adds into iTunes is cool.

You can visit my iLike profile if you like. And, if you're using iLike, add me as a friend.

Wednesday, December 06, 2006

ps2pdf tip: How to Get Around the "broken" ps2pdf Arguments

I through hours with a ps2pdf problem. Thank God someone on the PostScript news group managed to help me out. Here's the story for posterity's sake.

I'm currently working on a LaTeX document with some photos in it. As I'm using the PowerDot class, which is incompatible with pdflatex, I need to convert all my images to EPS and use ps2pdf to get my final PDF document. On the first attempt, I used the command

ps2pdf file.ps file.pdf

and it worked, except that my photos came out all muddy, a result of over compression. So, I added the option to turn off compression,

ps2pdf -dEncodeColorImages=false file.ps file.pdf

and end up with the wonderfully obtuse error message

Error: /undefinedfilename in (false)
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push
Dictionary stack:
--dict:1122/1686(ro)(G)-- --dict:0/20(G)-- --dict:70/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
MiKTeX GPL Ghostscript 8.54: Unrecoverable error, exit code 1


It turns out that ps2pdf on Windows is a batch file, and batch files do not accept = in an argument. I had no idea that this was the case, but so it is. The solution, which is annoyingly absent in the documentation, is to replace = with #. Thus, the command on windows should be,

ps2pdf -dEncodeColorImages#false file.ps file.pdf

Like that, it works. And, I get my beautiful uncompressed photos in my document.

Monday, December 04, 2006

Emacs Tip: No Tabs Whatsoever

I my last post, I tried to describe how to get rid of tabs in Python mode, and managed to not get it quite right. The previous command, python-guess-indent, really only turns off the indent guessing, but doesn't actually remove the tabs. It just happens that tabs are only used for every other indentation level. I had only tested the first level and missed that the tabs are still inserted later in.

So, to get rid of all tabs all the time, add the line (setq-default indent-tabs-mode nil) to your .emacs file. This turns off the replacement of spaces with tabs globally. Hooray! tabs are gone.

Friday, December 01, 2006

Emacs Tip: Troublesome Tabs in Python Mode

The Python mode in Emacs 22 (using python.el, not the python-mode.el from XEmacs) has a nice feature of deducing the spacing style based on the spacing and tabs that already exist in the file. Most of the time, it works really well, but, it does make getting rid of large tabs difficult. So, if you're having problems getting rid of tabs, simply toggle the indent guessing mode with the command python-guess-indent and just use the default Python mode settings for indentation.

Thursday, November 30, 2006

Python Tip: Make Python & Emacs Play Nice on Windows

I've discovered that making Python 2.4.4 work well under Emacs 22 on Windows has a few speed bumps. I'm not sure if these problems apply to other combinations of versions, but they may. Here's a list of things I had to do to make for a happy working environment.

To Run Python in Emacs
To Run Using Pychecker
  • Download the pychecker package
  • Decompress it and go to the extracted folder in a Command Prompt
  • In that folder, run the command python setup.py install
  • Use C-c C-v to run the python code loaded in the current buffer with pychecker
Unresolved Problems (I'm Working on These, Be Patient)
  • It seems that the debugger (pdb) is set up differently with Python 2.4.4 under Windows than other configurations. Consequently, Emacs' calls to pdb are all wrong.
  • When the Python interpreter is loaded into Emacs, it appears to be in a text-only mode. Running programs with graphics does not seem to work.

Wednesday, November 29, 2006

I'm On Skype

I've finally jumped on the Skype bandwagon, though I'm not sure that I'm happy about it. I like the technology behind it, and it does fill a certain set of needs very well (in my case, I need it for work). But, the client is terrible. It's cluttered with buttons and features and labels and big shiny things. I'm having a bit of difficulty figuring out what it can and cannot do. In contrast, Google Talk, my preferred client, is clean, simple, and very easy to use. So, in the end, I'm now running both.

You can search for me on Skype either by my email, smithco@gmail.com, or by my account name, doctor_colin_smith. And as always, you can find me on Google Talk by my email.

Sunday, November 26, 2006

Crud, I've Lost My DS Stylus, Again

Somewhere between now and yesterday, I've lost my DS stylus. Unfortunately, this was my spare; I lost my first one in spring. So now, until I can find a place that sells replacement styli, I won't be playing certain games. Crud, that's no Metroid, no Meteos, and no Castlevania. At least, I still have Mario Kart and Tetris to enjoy.

Monday, November 20, 2006

Visual C++ Tip: Visual C++ is Broken

Once again, I feel the urge to severely beat the people responsible for Visual C++.

I've once again run into examples of severe stupidity in this compiler. It seems that somehow,
Visual C++ got released without someone checking to see if the standard libraries can actually be compiled at the highest warning levels (for Visual C++ 8, that's with the option /Wall).

It really is quite essential for best practices that a compiler can compile it's own standard libraries at the highest warning levels without producing warnings. Otherwise, it causes obfuscation and hides legitimate messages related to the users' code. What's worse, the warnings produced from the standard library are completely opaque.

Here's an example of the warnings I've been given by the compiler.
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\string.h(141) : warning C4619: #pragma warning: there is no warning number '4609'
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\wchar.h(116) : warning C4820: '_wfinddata64i32_t' : '4' bytes padding added after data member '_wfinddata64i32_t::attrib'
C:\Program Files\Microsoft Visual Studio 8\VC\INCLUDE\wchar.h(121) : warning C4820: '_wfinddata64i32_t' : '4' bytes padding added after data member '_wfinddata64i32_t::name'
The first one is a real gem. A warning that there's a warning that doesn't exist. And I think the second one is an indication that there's a nasty shortcut for memory initialisation somewhere. Ugh.

The only lesson here is that the compiler option /Wall is completely unusable. So, use /W4 instead. It's less rigorous, but at least, there's fewer strange warnings emitted from the compiler regarding the standard library at that level. Few enough that they can be disabled or filtered out.

Links to my CV

I've posted before that I've posted my curriculum vitae over at Emurse. However, I only just now realised that I never made a proper, easy to find link on side bar of this page after switching up to Blogger Beta. Now, my curriculum vitae is easily available on the side bar in several formats. Just click on the one you'd like, especially if you want to offer me a job.

Friday, November 17, 2006

I'm On Multiply

After all the hubbub about Multiply over at MOG, I figured I'd give it a try. I now have a page at smithco.multiply.com. If you're on that network, or want to give it a go, feel free to add me as a contact over there.

So far, I'm liking it. It has a bunch of nice aggregation features mashed up with a bunch of nice social network features. And, it does all that with a nice, clean, easy to use, stylish interface. And the best part is, it is an augmentation of my existing networks, not a replacement. There's a good chance that I'll stick with Multiply for a while.

Visual C++ Tip: How to Enable Standard C++ Keywords

The people at Microsoft responsible for Visual C++ need to beaten with a stick. Those responsible for the documentation should be beaten severely.

Once again, I just finished another round of frustration with the non-compliance problems of Visual C++ 8. One would think that by six years after the ISO standard, they would get around to having all the embarrassingly glaring compliance issues sorted out, but sadly, it is still the case that simple, conforming C++ programs will not easily compile.

My current frustration is that, by default, Visual C++ has the boolean operator keywords disabled. That's right, by default, Visual C++ has certain, standard C++ keywords disabled. And it isn't some obscure functionality that I'm referring to, it's the keywords for the logical boolean operators.

It is possible to enable them with the option /Za. To be clear on this, we can refer to the MSDN documentation for the /Za option,
/Za flags language constructs not compatible with either ANSI C++ or ANSI C as errors. /Ze enables Microsoft extensions.
Uh oh, it looks like Microsoft tied two bits of unrelated functionality together into one compiler option, and left one of the bits undocumented. I think I have the full story figured out now, but caveat lector! We've landed in an undocumented, side-effect territory. It seems that we can either have the standard keywords or the language extensions, but not both. Now, most of the language extensions are useless, losing them is no problem, but there is an exception here. The keyword "extern" is erroneously considered a language extension by Microsoft. If you need that very useful keyword, you may run into problems.

Like I wrote at the start of this post, the people at Microsoft responsible for Visual C++ need to beaten with a stick. Those responsible for the documentation should be beaten severely. The design choice here is a shining example as to just how bad the compiler actually is.

Thursday, November 09, 2006

Silver Vase Bromeliad

Silver Vase Bromeliad, originally uploaded by smithco.

Thursday, October 26, 2006

C++ Tip: Stream Iterators

Write an item n times to an output stream

Solution A: Write a for loop

data_type x = value
for (unsigned int i = 0; i > n; ++i)
  std::cout << x;

Solution B: Use an iterator and an algorithm
std::fill_n(std::ostream_iterator<data_type>(std::cout), n, x);

Solution A has the advantage of simplicity. Almost everyone can remember how to code a for loop. However, Solution B serves as a neat, albeit somewhat trivial, example of the use of a stream iterator working with an algorithm. This is a powerful combination that is rarely explored. So, next time there's something interesting to be done with streams, remember that there is a lot of potential in using the algortihms in the standard library.

I ran some tests to see how the performance of the two solutions compare. With g++ 3.4.2 (mingw-special), there's no difference, regardless of the optimisation options. So, do not hesitate to use the standard library for fear of poor performance.

Wednesday, October 25, 2006

View my (mostly empty) calendar

I've made my calendar available at the bottom of this page. For now, it's mostly empty, but I'm starting to use it more and more. Alternatively, you can go directly to my calendar on Google Calendar.

Tuesday, October 24, 2006


IMG_5968, originally uploaded by smithco.

We spent a day in Aigues-Mortes, a little town held inside a medeval ramparts. It just so happened that we arrived on their Férias (bull festival).

See the whole photo set.

Wednesday, October 18, 2006

Le Pont du Gard

IMG_5808, originally uploaded by smithco.

The Pont du Gard (in the Provence region of France) is one of the largest of the Roman constructions. See it photographed from nearly every angle in a Flickr set

Friday, October 13, 2006

LaTeX Tip: Typesetting Nice Fractions or How to Make xfrac Work

One reason that we all love LaTeX is that it does a beautiful job of typesetting mathematics, provided that you're in an equation environment. Unfortunately, the typesetting of mathematics in inline text does not always work well.

One major problem that can occur is that fractions set inline in text either forces some extra space above and below the line of text or fails to nicely follow the text's current formatting.

The solution is to use the xfrac package, a package that solves all the nasty typesetting issues for fractions. Unfortunately, xfrac doesn't work if it is installed in the default way. A little LaTeX expertise is needed to coerce it into working. The instructions to do so with a MikTeX installation follow (the instructions for other LaTeX installations should be very similar).
  1. Do a full update of using the MikTeX Update Wizard
  2. Install the xfrac package, either automatically by including it in a document or using the MikTeX Package Manager
  3. Get the LaTeX project repository download xbase.tgz, the base package for the experimental features (direct link to the file)
  4. From xbase.tgz, extract the file xbase.ins
  5. Run latex on xbase.ins (the exact command is latex xbase.ins)
  6. Copy the generated style files (template.sty, ldcsetup.sty, xparse.sty, and xparse.sty) to the appropriate places, such that we get:
    • C:\texmf\tex\latex3\template\template.sty
    • C:\texmf\tex\latex3\xparse\ldcsetup.sty
    • C:\texmf\tex\latex3\xparse\xparse.sty
    • C:\texmf\tex\latex3\xtools\xtools.sty
  7. Update the package index (the exact command is texhash)
Now, it is possible to set fractions nicely anywhere in a document with the command \sfrac{numerator}{denominator}. All the details of this command can be found in the xfrac documentation (PDF).

Wednesday, October 04, 2006


I've just about finished overhauling this journal so that it uses the new Blogger Beta engine. So far, it all seems happy and good and untested. If you hit any problems, let me know so I can fix it. And always, I love to get criticisms on the design, so feel free to comment on everything here.

Sunday, September 24, 2006

Another Rainy Day

It's been a rainy weekend and my apartment is small and cramped. I just figured everyone would want to share in the boredom.

Saturday, September 23, 2006

Tusitala Edition

Tusitala Edition, originally uploaded by smithco.

For more info on 'tusitala' in the Samoan language, see http://www.websters-online-dictionary.org/translation/Samoan/tusitala

Tuesday, September 19, 2006

Peter Easton -- A Most Accomplished Pirate and a Great Canadian

In honour of the International Talk Like a Pirate Day, I suggest everyone read up a bit on Peter Easton, a Canadian who was a most accomplished pirate. At the height of his career, he commanded forty ships and five thousand men. He was both a hero and a terror on the seas off Newfoundland.

Read about him on Wikipedia

Saturday, September 16, 2006


Cowdenbeath, originally uploaded by smithco.

The last day of my holiday was spent up in Cowdenbeath. There's nothing particularly special about Cowdenbeath. It's just a small, industrial town where the mines were closed down some time ago by Margaret Thatcher. But, it is the place the Smiths are from; it was good to see the place and the people who make up a part of my heritage.

View all my photos from Cowdenbeath

Holyrood Abbey

Holyrood Abbey, originally uploaded by smithco.

The next three days of my holiday were seeing the sights and history of Edinburgh. The two highlights there were most definitely Arthur's Seat, the extinct volcano that dominates the city's skyline, and Holyrood Palace, the Queen's residence in Edinburgh.

View all my photos from Edinburgh

Whiskey Live!

Whiskey Live!, originally uploaded by smithco.

The first two days of my holiday were in Glasgow. The highlight was the Whiskey Live! show. Unfortunately, I only got one good photo from the show, it's as if my photographic abilities are inversely proportional to my blood-alcohol content.

View all my photos from Glasgow


SCOTTISH NOT BRITISH, originally uploaded by smithco.

View all the photos from my trip to Scotland in one set


I've finally caught up on a week's worth of unread email, RSS feeds and web activity. I'm guessing that it was about 500 messages to consume, but I'm ready to take on the world again!

I would also like to point out that this is sure proof that the Internet is in no way an aid to productivity.

And the first consequences of coming back from holiday

Well, after crawling out of bed today, I noticed a few things.
  1. I have no clean shirts or socks. As my favourite philosopher pointed out, "There are only two things certain in this world: death and laundry".
  2. The only thing in my fridge is Pineapple juice, Heineken and coffee grounds.
  3. I forgot to empty the coffee pot before I left and now it's full of mould.

Is it too late to go back to Scotland?

Friday, September 15, 2006

Back from Scotland

Just got back from Scotland last night. Holidays are always too short. I'll be posting stories, photos, and videos up in spurts. There's a bit too much to throw up all at once.

Tuesday, September 05, 2006

Three and a Half Months

Three and a half months until I return to civilisation.

I'm tired of the bad food and the abysmal quality of products. I've had enough with the complete lack of any sort of service. I've had enough with incompetent people lodged into public institutions. And I'm especially fed up with the absolute lack of manners and respect for others here.

This place is not a good place. This society is messed up. Three and half months feels like an awful long way away.

Tuesday, August 29, 2006

Dr. Smith's Résumé

I'm finally getting my résumé back together. And to feed my Web 2.0 addiction, I'm trying out Emurse to put my résumé together. Genrerally, it's working very nicely. My only complaint is that the resulting document is a little too "Word-like" - though I'm not entirely sure what I'd do to improve on that. Given that I'm never quite sure how to format or my résumé, I'm quite happy to have found this tool.

Visit my résumé at Emurse

Emacs Tip: No More Than a Single Instance of Emacs

In my previous post on Emacs, I pointed out that after modifying the .emacs file to include the initialisation of gnuserv, there was an error message emitted when more than one instance of Emacs is launched.

This error comes from the fact that gnuserv only works if there is a single instance running.

As it turns out, this problem has a very simple solution. Instead of launching Emacs using the program runemacs.exe that comes with the aforementioned Emacs distribution, launch Emacs using the program gnuclientw.exe that comes with the gnuserv distribution from the previous post. This program will run Emacs as a client if gnuserv is already running, and if not, then it will run Emacs regularly.

This usage has a few nice effects. Firstly, no more than one Emacs window will exist; your desktop will stay tidy. Secondly, opening a file that is already open will take you to the same editing position; you don't risk editing the same file in two separate processes.

The only catch is that this requires re-associating all the file extensions to gnuclientw.exe instead of runemacs.exe and changing your shortcuts. Unfortunately, this is a bit of a pain under Windows, but worth-while when it's done.

I think that this post wraps up the "the essentials of how to get a great LaTeX environment for Windows" saga. There will be future posts, but they'll be about extra features (look for something on either folding or outlining soon). The basics are all nicely described now.

Monday, August 28, 2006

Inkscape Tip: Use Inkscape on the Command-line

It turns out that Inkscape (an SVG editor) has a few useful command-line options for non-interactive use. However, these are only documented on the Inkscape website (Manpage of INKSCAPE), but not in the documentation accessible from the program.

The real gem in the command line options is are the export options. These are a command-line interface to load up an SVG file and export as another format in a non-interactive format. This allows for the inclusion of vector format conversions in scripts.

Since the well-known image conversion utility ImageMagick does not have vector-to-vector format conversions, this is a very useful tool.

Particularly, this is an issue when using Inkscape (or other tools that use SVG) to create images for LaTeX documents, where one of EPS, PDF or PNG is typically used.

To convert an SVG file to an EPS file use
inkscape -f file.svg -E file.eps
to a PDF,
inkscape -f file.svg -A file.pdf
and to a PNG,
inkscape -f file.svg -e file.png

Friday, August 25, 2006

Adobe Reader Tip: Make Reading Easier With the Accessibility Features

As a followup to the previous entry on eye strain, I've been looking for a way to make reading documents easier.

In Adobe Reader (aka. Acrobat Reader), it is relatively simple to set up a low eye-strain environment for reading. The magic happens with the accessibility options.

To set up the accessibiliy options
  1. Go to the Preferences dialog box, either with Ctrl-K or from the menu by Edit->Preferences.
  2. Select Accessibility from the list on the left.
  3. Enable Replace Document Colors (check-box)
  4. Select Use High-Contrast colors from the radio-selection
  5. From the High-contrast color combination select Yellow text on black.
Then, when reading a PDF document, go into full screen mode and maximise the size of the text.
  1. Goto Full-screen mode, either with Ctrl-L or View->Full Screen
  2. Use Fit-Visible mode, either with Ctrl-3 or View->Fit Visible
This will drastically reduce the amount of light emitted from the screen, keep the contrast high, provide large text and remove any distracting visual elements when reading. Personally, I find that this helps immensely to make reading electronic documents more comfortable.

Thursday, August 24, 2006

An Experiment in Eye Strain

Oy! My eyes have been a bit sore lately. So has my back, head and moustache. I've been sleeping badly too.

I think it comes down to a bad work setup. I spend pretty much all my time at a keyboard, so when things are wrong with my setup, I suffer. I've known about a few obvious problems, the chief one is that I'm on a laptop without an external monitor and I do not have a good desk or a good chair, so I'm slouching and hunched over all the time.

But, I think I've realised that I have another issue that is not well explored in the good work environment lore. I have a screen that's bright, but the matte finish causes all the brightness to go diffuse and glaring. There's quite a large amount of light hitting my eyes all day and the scattering effects from the matte finish could be messing with my visual cortex. I figure that if the visual signals are a bit messed up, the brain has to work that much harder to understand the signals its receiving.

Thus, my experiment is to run mt screen at minimum brightness. Less light assaulting my eyes and relatively more light is going cleanly from the screen to my eyes. After an hour of cranking down the brightness, I'm already feeling better. Now, I just need to see if this is a short term effect or really a benefit. Afterall, it could just be that I need to relax and get out a bit this weekend.

I'll follow this up in a week or so to report the results.

Monday, August 21, 2006

Emacs Tip: Making Emacs Work With Yap

As a followup to my previous post about the joys of the newest version of Emacs, AUCTeX and Preview-TeX on Windows, I now present how to make Emacs invokable by another application on Windows. It all has to do with the magic that happens when source-specials are enabled in AUCTeX

Here's the current scenario:
  1. Edit a LaTeX file with Emacs
  2. Run C-c C-c to compile
  3. Run C-c C-c to view
  4. Yap will load up with the DVI file in the spot that is currently being edited in Emacs
  5. Double-click in a spot in the DVI file in Yap and ... !?!
What follows are the instructions for turning that !?! into "jump back into Emacs at that spot in the LaTeX File", just as we want.

It all comes down to the problem that the implementation for Emacs' client-server architecture isn't complete on Windows. However, there is an external implementation, the one used in XEmacs, that works rather well.

This is hardly an automated task, so don't run through these instructions too quickly.
  1. Download gnuserve for Windows. It's near the bottom of the page. I used "newer and hopefully more compatible version".
  2. Unzip the file that was just downloaded.
  3. From the zip file, copy the executable files (*.exe) to the bin subdirectory folder and the Emacs Lisp files (*.el) to the site-lisp subdirectory of your Emacs folder.
  4. In your .emacs file, add the lines
(load "gnuserv")

If everything worked, you can fire up Emacs and enjoy some fantastic Emacs-Yap editing interaction

  • It seems that there may be an issue with running more than one instance of gnuserv. I'm looking into that.
  • It seems that the version of gnuserv that I'm recommending may be a bit outdated or has had it's development abandoned. However, I can't find a newer version. Hopefully there will be a development soon on this front.

Friday, August 18, 2006

LaTeX Tip: Emacs, AUCTeX and Preview TeX - A Fantastic Editing Environment

I think I've discovered the best new environment for LaTeX under Windows, it's Emacs 22 with AUCTeX 11.38. It's the sort of setup that mostly just works. With a bit of tweaking, it really does just works. How rare it is to find this situation in the world of software!

This post covers how to get and install this combo under Windows, how to do a few useful customisations and a few useful commands.

The best place to start is to download the pre-built Windows version of Emacs with the latest AUCTeX built in (download here). The installation of this version is dead simple: download it, un-zip it and run the program runemacs.exe in the bin directory.

First off, the latest Emacs 22 has fantastic Windows integration, way ahead of Emacs 21 or XEmacs. Things like cut-and-paste now actually work. It's worth upgrading to Emacs 22 if you're running any other version of Emacs or Emacs variant.

AUCTeX is a package that includes a whole bunch of useful commands, syntax highlighting and formatting for LaTeX and related programs. The most useful AUCTeX command is C-c C-c, which will compile and view your LaTeX document.

Preview-TeX is now built into AUCTeX and works with both regular LaTeX and PDF LaTeX documents (i.e. it works with EPS, PDF and PNG images and outputs). Preview-TeX will go through your LaTeX document and interpret and display in place various LaTeX elements, including section headings, equations and figures.

A few useful Preview-TeX commands are
  • run the preview on the whole document: C-c C-p C-d
  • run the preview at a point: C-c C-p C-p
  • run the preview on an environment: C-c C-p C-e

Customising the Emacs Startup
The only annoyances with the Emacs startup is that it always displays the splash screen and it does not necessarily start at a nice size. This can be easily fixed by adding a few lines to the .emacs file (usually at C:\.emacs).

To disable the splash screen, add the line
(setq inhibit-startup-message t)
and to set the window size, in the number of displayed characters, add the lines
(set-frame-height (selected-frame) 40)
(set-frame-width (selected-frame) 80)

Make AUCTeX Play Nice with MikTeX
By default, AUCTeX expects that the LaTeX installation is a typical UNIX one, which is rarely the case with a Windows environment. As it happens, AUCTeX can reconfigure itself nicely to use the MikTeX (one of the most popular implementation of LaTeX for Windows) setup quite easily. It is simply a matter of adding
(require 'tex-mik)
to the .emacs file.

Make AUCTeX Jump to the Current Position in the DVI File
By Default, when AUCTeX invokes the DVI viewer, it does so without any fancy options. This means no jumping to position or inverse editing. This is easily enabled by default by adding
(setq TeX-source-specials-mode t)
to the .emacs file.

Monday, August 14, 2006

Finally, A Real Vacation!

For the first time in ages, I'm going to be taking a real vacation. I really don't remember the last time I went somewhere strictly for a vacation. It must have been a family vacation when I was still young.

So for me, it's one week in Scotland in September.

Wednesday, August 09, 2006

Math Tip: Find the Angle Between Two Vectors

I almost always forget how to do this and need to rederive it every time I need it, I'm posting the algorithm here.

Assume two unit-length vectors A and B. The dot product of the two gives us the cosine of the angle between them.

cos θ = A·B.

Of course, that's the easy part to remember and, of course, everyone forgets that

cos-1(cos θ) ≠ θ,

but rather

cos-1(cos θ) = ±θ.

So, how to properly determine if it is +θ or -θ? The answer is to also check the sign of the cosine of the angle between A and C, the vector that is B rotated by π/2. Then, if the signs do not agree (i.e. A·B < 0 and A·C > 0 or, A·B > 0 and A·C < 0), θ needs to be negated.

Sunday, August 06, 2006

A Short Trip To Bézier

IMG_4893, originally uploaded by smithco.

Took a trip to Bézier today. Turned out that the place is dreadfully boring. At least, I managed to get a few decent photos. View the whole photo set.

Friday, August 04, 2006

Del.icio.us Badge

I've added a del.icio.us badge on the right of this page. Nothing too special, but it does allow one more networking opportunity.

Saturday, July 22, 2006


Cigale 2, originally uploaded by smithco.

These little critters hide in the trees around Montpellier. Somehow, these insects, about an inch long, make an astoundingly loud noise. It's kind of a cricket-like noise, but higher pitch and much, much louder. There's almost always at least one per tree and can be heard from pretty much anywhere in the city. They start in the morning and stop when the sun goes down. One more reason as to why I'm not enjoying the summer here.

Wednesday, July 19, 2006

Global warming could lead to a frozen Europe

A brief explanation of how changes in the wind cycles of the Atlantic could breakdown and lead to a much colder climate in Europe.

read more | digg story

Tuesday, July 18, 2006


Ok, I finally caved - I set up a MySpace page.

Basically I did this to keep tabs on various music groups. It seems to be the only thing that MySpace is really good for. But, on the off chance you, my unfaithful reader, decides to add me as a friend on MySpace, that would be cool too.

Visit my MySpace page.

Now all I have to do is figure out how to make my MySpace page not look ugly. I've heard rumours that this is actually possible.

Sunday, July 09, 2006


Visit my MOG page! My online journal of the music I listen to.


Monday, June 26, 2006

C++ Tip: dimnum - C++ classes for storage and manipulation of dimensionful numbers

dimnum documentation

Dimnum is a library for handling measurement units. Unit conversions and correctness checks are done at compile time. This is a very nice way to ensure that units don't get screwed up when writing simulations.

However, the documentation for this library is a bit lacking. So, here follows a brief example of how to use it. In this example, a unit type that is included by default is created and a simple calculation is done to show the output.

#include <dimnum/dimnum.hh>
#include <dimnum/si.hh>

// Create a dimensional base for force
namespace dimension {
  typedef powers<1, 1, -2, 0, 0, 0, 0> force;

// declare unit used for force
default(si, force, newton, 1, 1, 0, "N");

// create the unit abbreviations
// library bug - this should be done automatically
const char unit::meter::abbr[] = "m";
const char unit::newton::abbr[] = "N";
const char unit::joule::abbr[] = "J";

int main()
  si::length<double> l(3.0); // 3 meters
  si::force<double> f(10.0); // 10 newtons

  // output 3m x 10N
  // The first result is in SI base units
  // The second result is in the SI derived unit, Joule
  std::cout << l << " x " << f << " = " << l * f << " = " << si::energy<double>(l * f) << std::endl;

While useful, it should be noted that there are three small problems: the documentation is sparse, unit abbreviations need to be created for all the units used and there aren't many units available by default. However, given how increadably useful this is, those little problems shouldn't be reasons not to use this library.

Thursday, June 22, 2006

The CBC website is 10 years old!

A neat overview of how one of the web's older websites has evolved over the years. Some nice photo overview of this evolution are included. See the site design and the back-end hardware develop from old-and-broken to new-hotness.

read more | digg story

Thursday, June 08, 2006

Google Spreadsheets

Thanks to Break over on Digg, I now have access to Google Spreadsheets. Very Cool. Post your email if you need an invite.

Saturday, June 03, 2006

Wine Journal on the Side

Way down on the right side of this jounal, my wine journal on Cork'd is now displayed. Click on any of the entry titles to read the full wine review.

Tuesday, May 30, 2006


I've taking a liking to Comte lately. Definitely one of my favourite amongst the French cheeses.

Saturday, May 27, 2006

Cork'd - Profile for Colin Smith

The fine wines that I'm enjoying in France.

Cork'd - Profile for Colin Smith

Le Pont d'Avignon

Le Pont d'Avignon, originally uploaded by smithco.

On Friday, I took a trip to Avignon. Saw all the touristy stuff, the Musée Lapidaire, the Palais des Papes, the Musée du Petit Palais and, of course, le Pont d'Avignon.

Visit the photo set from Avignon

Thursday, May 25, 2006

Collaborative Tools in Science

The question of how to de good collaborative work, particularly in my own work as a scientist, is one that I've been thinking about quite a bit lately. I've decided that a journal dedicated to this topic is in order. So, I've started Collaborative Tools in Science, a journal dedicated to the discussion of methods, tools and problems in collaborative work in science.

Saturday, May 20, 2006

Tiny view to the sky

Tiny view to the sky, originally uploaded by smithco.

I was down at the lake again topday with my camera. On a whim I took the this photo. Not too fancy a set up done on one try.

Somehow, I ended up with fantastic lighting, colours, framing, depth of field and focus. It's like everything went right with this photo.

I have to boast a bit, I think it may be one of the best flower photos I've taken.

Friday, May 12, 2006

I'm on ClaimID

I've set myself up on ClaimID, a website for online identity management.

You can view my ClaimID page by clicking here or on the little hCard button anywhere it's found on my websites.

Thursday, May 11, 2006

A Trip to Nîmes

The Arena in Nîmes, originally uploaded by smithco.

Last Monday, we took a trip to Nîmes.

View the whole photo set on Flickr.

I also have a video of some Gladiators on YouTube.

Saturday, April 29, 2006

iTunes tip; import & export OPML for podcasts

I found import & export instructions to go between iTunes podcast subscriptions and an OPML file at

J G dot com: iTunes OPML (!)

Pretty useful and easy, but a little hidden.

Monday, April 24, 2006

The Way to St. Guilhem-de-Désert

The Way to St. Guilhem-de-Désert, originally uploaded by smithco.

On Sunday, Fred and I took a hike up in the hills behind St. Guilhem-de-Désert.

View the whole photo set on Flickr.

Friday, April 21, 2006

High Score

High Score, originally uploaded by smithco.

I fell into zen-like state while playing Tetris DS and managed to pull one heck of a high score. And since I'm kinda bored, I thought I'd post it around the net.

At the game's end: level 57, 575 lines cleared, final score of 1166842.

Hopefully This Will be OK

I've decieded to try putting advertising on this webpage. Maybe I'll successfully get a bit of coffee money from this. And if it comes to naught, or if my small audience finds it annoying, it can always be removed later.

Happy Little Minnows

I've been having fun making short nature films using the video mode on my camera. My fovourite (shown below) is a bunch of minnows at the edge of the lake.

You can hop over to my videos on YouTube to see the rest.

Friday, March 24, 2006

A presentation that I will give on March 27, 2006

Colin's Page - Colin's Home Page:

Des outils utiles sur l’internet - March 27, 2006

A short presentation (in French) to list and introduce some web 2.0 applications that are useful for academics. In this presentation, I Want To, CiteULike & Basecamp are covered. This may be the first presentation in a series, depending on the expressed interest.

Friday, March 17, 2006

US security-related departments fail on cybersecurity

The last line of the article says it all: "Will it take a major computing disaster before the government makes information security more of a priority?"

read more | digg story

Friday, March 03, 2006

LaTeX style: powerdot-black

Powerdot-black is a basic-black style that I wrote for powerdot. It can be used to make simple slides with white text on black slides. To use this style, just drop the file, link below, into your powerdot directory where all the other powerdot style files are.

Download the file

Colin's new place - Colin's New Home Page

I now have a space on Google Pages. I'll use this to post files & stuff in static form.

Colin's new place - Colin's New Home Page

Tuesday, February 14, 2006

iTunes tip: Finding a gift redemption code

Short story:

Not long ago I sent a music gift through iTunes. When the recipient clicked on the "Redeem Now" button in the email, iTunes prompted for the 12 digit redemption code. Now, just to make the situation interesting, the 12-digit code was not displayed anywhere in the email. Apparently, the gift of music was not to be easily redeemed.

After much frustration, I discovered that the redemption code is hidden in the email to the recipient. The code is the last 12 characters in the link that the "Redeem Now" button is attached to. So a copy & paste job from the href attribute in the email to a text editor and I had the redemption code.

Considering that Apple is known for the fantastic user-experience, this incident raises some questions. Particularly, the question "What the heck were Apple's designers thinking?" comes to mind. Any vital piece of information should be accessible in more than one way just in case the information flow doesn't work out as planned. That's a basic design principle.

I'm not angry at Apple, just disappointed.

Tuesday, February 07, 2006

I'm on Newsvine!

smithco.newsvine.com - smithco

Somehow I goy lucky and got one of the randomly sent out Newsvine invites. And so now I have a Newsvine profile at the above link. Send me an email if you want an invite from me.

Monday, February 06, 2006

C++ Tip: Easy install of Boost into MinGW

Since Boost is mostly implemented as a set of header files, it is possible to just drop the boost directory in the Boost distribution into a compiler's include directory for the C++ header files. For the case of MinGW with a default install, that directory is C:\MinGW\include\c++\3.4.2\ (adjust that for a different install location or version).

Tuesday, January 31, 2006

XEmacs tip: Add a Webpage entry for BibTeX

A useful BibTeX entry to have is that for BibTeX. The first step is to install the urlbst package. Then, to have the entry play nicely with the BibTeX autocompletion features in XEmacs, add the below code to the file init.el.

(defun my-bibtex-hook ()
(setq bibtex-mode-user-optional-fields '("location" "issn"))
(setq bibtex-entry-field-alist
'("Webpage" ((("url" "The URL of the page")
("title" "The title of the resource"))
(("author" "The author of the webpage")
("editor" "The editor/maintainer of the webpage")
("year" "Year of publication of the page")
("month" "Month of publication of the page")
("lastchecked" "Date when you last verified the page was there")
("note" "Remarks to be put at the end of the entry"))))
(add-hook 'bibtex-mode-hook 'my-bibtex-hook)

XEmacs tip: Customise the mode based on file extensions

While most of the default modes based file extensions are sensible, it is good to know how to override the defaults.

The following code added to the file init.el will change the mode loading such that files with the extensions .l (the default is lisp-mode) and .vvp (an extension is not known by XEmacs) are loaded with the c++-mode.

(setq auto-mode-alist
'(("\\.l$" . c++-mode)
("\\.vvp$" . c++-mode))

XEmacs tip: disable overwrite by INS key

It's easy to accidently go into overwrite mode by accidently hitting the Insert key. To prevent this, it is possible to remap the key by adding the following line to the file .xemacs/init.el.

(global-set-key [insert] "")

Tuesday, January 24, 2006

Interesting election results in Québec

I just noticed an interesting trend in the election results for the ridings in Québec. In everycase where the incumbent lost, there's a fixed pattern. Where a Liberal lost, the riding went to the BQ. Where a BQ lost, the riding went to a Conservative (except for one that went to an independant).

Is there a reasonable interpretation? I think it can be summed up in two points.
  1. Discontent in Québec with regard to the ad scandal resulted in a movement against the federal government to the seperatists.
  2. Those who are shifting away from seperatism to federalism are siding with the Conservatives.
At least, that's my take on the Québec results.

Information source (cbc.ca/canadavotes)

Monday, January 23, 2006

First photos from Montpellier

The lake near my apartment, originally uploaded by smithco.

The first photos from my adventure in France are up on Flickr!

link to the set http://www.flickr.com/photos/smithco/sets/72057594052666401/