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,

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

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

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

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.

Wednesday, November 29, 2006

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

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

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.

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.

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

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.

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.

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, October 26, 2006

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

DiscussionSolution 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.

AddendumI 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.

Friday, October 13, 2006

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, xfracdoesn'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).

Do a full update of using the MikTeX Update Wizard

Install the xfrac package, either automatically by including it in a document or using the MikTeX Package Manager

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.

Tuesday, September 19, 2006

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.

Saturday, September 16, 2006

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.

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.

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.

Tuesday, September 05, 2006

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.

Saturday, September 02, 2006

Tuesday, August 29, 2006

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.

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.exeinstead 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

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.

Friday, August 25, 2006

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

Go to the Preferences dialog box, either with Ctrl-K or from the menu by Edit->Preferences.

Select Accessibility from the list on the left.

Enable Replace Document Colors (check-box)

Select Use High-Contrast colors from the radio-selection

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.

Goto Full-screen mode, either with Ctrl-L or View->Full Screen

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

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.

Monday, August 21, 2006

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:

Edit a LaTeX file with Emacs

Run C-c C-c to compile

Run C-c C-c to view

Yap will load up with the DVI file in the spot that is currently being edited in Emacs

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.

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.

In your .emacs file, add the lines

(load "gnuserv")(gnuserv-start)

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

Caveats:

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

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.

InstallationThe 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.

AUCTeXAUCTeX 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-TeXPreview-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 StartupThe 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

Make AUCTeX Play Nice with MikTeXBy 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 FileBy 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

Monday, August 14, 2006

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.

Wednesday, August 09, 2006

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.

Saturday, July 22, 2006

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.

Tuesday, July 18, 2006

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.

Monday, June 26, 2006

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>

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

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.

Thursday, May 25, 2006

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.

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.

Friday, March 24, 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 03, 2006

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.

Tuesday, February 14, 2006

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.

Monday, February 06, 2006

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

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 (cons '("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")))) bibtex-entry-field-alist)))(add-hook 'bibtex-mode-hook 'my-bibtex-hook)

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.

Tuesday, January 24, 2006

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.

Discontent in Québec with regard to the ad scandal resulted in a movement against the federal government to the seperatists.

Those who are shifting away from seperatism to federalism are siding with the Conservatives.