Tuesday, 31 August 2010

Import trips from a Garmin GPS device to Google Maps

One of the nice feature about Google Maps is the ability of sharing trips with friends or just storing them privately for later reference. Unfortunately the only advertised formats for importing trips are KML, KMZ and GeoRSS - none of which being widely supported by dedicated GPS units.

There are two ways to import GPX files - one that uses a hidden feature of Google Maps and a more elegant approach which converts the GPX files to KML.

Approach 1: Google Maps hidden GPX import

Google Maps does support GPX files, but for some reason they don't advertise it:


  1. Copy the GPX file from the Garmin device to your computer. On my Garmin eTrex Vista HCx, this can be done by mounting the device as USB drive or just by removing the microSD card.

  2. Go to Google Maps and make sure you?re logged into your Google Account.

  3. Create a new map: My Maps -> Create a new map. Enter a title and select the desired privacy setting.

  4. Click on ?Import?. You should get a dialog asking you to select a KML, KMZ or GeoRSS file. Even though it?s not listed among the supported formats, you can still select and upload a GPX file.


Approach 2: Convert the GPX files to KML

The preferred, long term approach would be to convert the GPX files to a supported format, such as KML. This can be done using a handy open source tool, GPSBabel - http://www.gpsbabel.org.


  1. Install GPSBabel from the above link.

  2. There are two ways to use GPSBabel - from its graphical user interface or from the command line. Unfortunately due to a bug in the GUI, we will need to use the command line version, in order to tweak its configuration settings. To make this process as painless as possible, you should add GPSBabel to your system path (e.g. the PATH variable on Windows and Linux, probably something similar on Mac).

  3. Open a command window / terminal in the folder where your GPX files are and run the following command:

    > gpsbabel -w -r -t -i gpx -f input.gpx -o kml,points=0 -F output.kml

  4. Go to Google Maps -> My Maps -> Create new map -> Import -> Upload your KML file



GPSBabel offers a multitude of options for converting GPS tracks - for more details, please consult its documentation.

Thursday, 3 June 2010

Is the glass empty or full?

Can we see the world through objective eyes, or are we always the slaves of our own experiences?

One of the things that make photography fascinating for me is the ability to capture the "world" as you see it. At first, one can be tempted to say that photography is just a perfect reproduction of reality, but most of the time, it's not even close to it. Why does a photo show this scene and not another one? Why does it have this subject? Why is it focused in this way and not another?

I think it's very hard to capture "reality" in an objective manner. Just the fact that you "capture" a piece of it, raises the question why this piece and not another one?

But does it really matter? Do we really want to see the world with cold, objective eyes? I highly doubt it. Perhaps there's always a hidden tendency in us to see something more; to enrich the cold features with our own details, to add colour to the grey shades, to see things that aren't there and to obstruct the things that we don't want to notice.

Sunday, 14 February 2010

"Nocturnes" by Kazuo Ishiguro

"Nocturnes" was my first reading encounter with Kazuo Ishiguro. Due to the nature of the book, a compilation of short stories on the theme of music at nightfall, I think it might be a bit different compared to his usual works.

What I noticed from the first pages was the exquisite language and descriptions. Even if you ignore the subject of the novel, you're still able to experience some pleasant emotions created by refined words. Unfortunately, I think some readers might have a few problems with this, as the essence of most stories lies in the language and expressions; in the emotions created by these and very little in the action or the actual events. Most of the time, the events might seem quite ordinary, not very dramatic - perhaps a bit absurd sometimes, but they wouldn't stand out on their own.

But if you ignore this and focus on the big picture, the experience is quite great. After all, it's not that hard to come with a dramatic ending, or with a complex plot, but you need a lot of talent in order to even come close to the expressiveness of the "Nocturnes".

There are a few recurring themes throughout the stories. First, all of them are build around music and how the characters are affected by it. It can take you to great heights, or it can throw you in the deepest abyss - yet, there's always an emotion.

There's also the theme of loss of identity - for example, the main characters from "Crooner" and "Come Rain or Come shine" both experience a feeling of lost identity. In "Crooner", we have Tony Gardner, a successful musician which is on a continuous journey of reinventing himself, even if it means giving up on the beloved ones. In "Come Rain or Come Shine" the narrator, Ray is asked to play the role of a complete failure, in order to help his best friends get back together. While it's not a very hard role for him to play, there's one very important bit which makes up for everything - his entire personality is built around his passion for old, slow blues, music. Due to circumstances, he's forced to reject it, even though deep inside it still means a lot to him.

Time is also an important dimension throughout the narrations. The characters are often portrayed at two stages in their life, with an emphasis on how much they were changed by the passing years. While they go through both good and bad experiences, it's impossible not to notice that they have lost something on their way.

Thursday, 28 January 2010

"The Road" by Cormac McCarthy

"The Road" is the desolate tale of a father and child through the aftermath of an unnamed catastrophic event. At first it might sound as just another post apocalyptic tale, but in reality, it's a lot more. It's about the inner states, transitions, the will to go further - and also about trying to cope with the remembrances of a golden past, when surrounded only by desolation.

One of the first things that I've noticed, perhaps also because I'm not a native English speaker, was the language style - to be more precise, the complicated, twisted expressions used throughout the book. It's definitively not the clean, concise English advertised nowadays - but an expressive and emotive version. Yes, I think this plays a major role in how the book "feels" to the reader: it creates a heavy, crushing mood.

The characters are quite few, actually there are only two main ones and some brief secondary roles. The odd thing about the main figures, a father and his child, is the fact that they have no names - perhaps in the new world there are no more identities, just two lost souls trying to stay alive for one more day.

It's also impossible not to be touched by the sensible relation between the father and his son. For him, the child is the only thing worth living for, but for the child, things are a bit different; because he never experienced life before the cataclysm, he doesn't miss anything, nor is he able to dream for a revived past. There is however something which animates him, but we're not told what exactly it is. One thing the child cares for is to remain good (the father also shares this feeling, though it's probably only because of the son). Now, this gets a bit more dramatic, as what does good mean in a world haunted by barbaric road warriors, cannibalism and total degradation? They both find it very hard to relate to good or bad, as there are no more values in the world - yet they use a symbol for this, the symbol of fire - they are good as long as they have the fire.

As for the structure of the book, it's not very well emphasised. I'm quite sure that the book would feel almost the same with some parts taken out, as most of the events are not really related to each other - nor do they contribute to the plot. If you're into complicated plots, then it's probably the wrong book for you. You can guess what is going to happen right after the first pages (or maybe even after reading this review). But I don't think it matters that much, as the value of the book is not in the plot, or in the action - it's in the expressed emotions. And it does a great job at expressing things.

I enjoyed this book a lot and I think it will stay on my mind for a very long time. Cormac McCarthy is really a master at playing with emotions, often I would sit late at night, with a glass of red wine and just enjoy the carnival of emotions created by his words.

As always, you can find below a few quotes which I liked.


"You forget what you want to remember, and you remember what you want to forget."

"All things of grace and beauty such that one holds them to one's heart have a common provenance in pain. Their birth in grief and ashes. So, he whispered to the sleeping boy, I have you."

"They sat at the window and ate in their robes by candlelight a midnight supper and watched distant cities burn."

"Rich dreams now which he was loathe to wake from. Things no longer known in the world. The cold drove him forth to mend the fire. Memory of her crossing the lawn toward the house in the early morning in a thin rose gown that clung to her breasts. He thought each memory recalled must do some violence to its origins. As in a party game. Say the word and pass it on. So be sparing. What you alter in the remembering has yet a reality, known or not."

"What if I said that he's a god? The old man shook his head. I'm past all that now. Have been for years. Where men cant live gods fare no better."

"Maybe you should always be on the lookout. If trouble comes when you least expect it then maybe the thing to do is to always expect it."

"Maybe he understood for the first time that to the boy he was himself an alien. A being from a planet that no longer existed. The tales of which were suspect. He could not construct for the child?s pleasure the world he?d lost without constructing the loss as well and he thought perhaps the child has known this better than he."

"He tried to remember the dream but he could not. All that was left was the feeling of it. He thought perhaps they?d come to warn him. Of what? That he could enkindle in the heart of the child what was ashes in his own. Even now some part of him wished they?d never found this refuge. Some part of him always wished it to be over."

"People were always getting ready for tomorrow. I didn?t believe in that. Tomorrow wasnt getting ready for them. It didnt even know they were there."

"When your dreams are of some world that never was or of some world that never will be and you are happy again then you will have given up. Do you understand? And you cant give up. I wont let you."

"Do you think that your fathers are watching? That they weigh you in their ledgerbook? Against what? There is no book and your fathers are dead in the ground."

"Perhaps in the world?s destruction it would be possible at last to see how it was made. Oceans, mountains. The ponderous counterspectacle of things ceasing to be. The sweeping waste, hydroptic and coldly secular. The silence."

"Do you remember that little boy, Papa?
Yes. I remember him.
Do you think that he?s all right that little boy?
Oh yes. I think he?s all right.
Do you think he was lost?
No. I dont think he was lost.
I?m scared that he was lost.
I think he?s all right.
But who will find him if he?s lost? Who will find the little boy?
Goodness will find the little boy. It always has. It will again."


"Once there were brook trout in the streams in the mountains. You could see them standing in the amber current where the white edges of their fins wimpled softly in the flow. They smelled of moss in your hand. Polished and muscular and torsional. On their backs were vermiculate patterns that were maps of the world in its becoming. Maps and mazes. Of a thing which could not be put back. Not to be made right again. In the deep glens where they lived all things were older than man and they hummed of mystery."

"There is no God and we are his prophets."

Thursday, 31 December 2009

"Brave New World" by Aldous Huxley

A few moments ago I finished reading "Brave New World" by Aldous Huxley and I wanted to share my thoughts on the book while they were still fresh.

While reading the book, I couldn't help not draw parallels between the utopian society depicted here and the one from Orwell's 1984. It's interesting how a few decades ago they imagined how the future might be - and perhaps also raised the attention on the dangers that might lurk the in darkness of time.

George Orwell's 1984 describes an oppressed society, afraid to take any action, paralysed and rendered unable to feel any sensation. A society of robots one might say, robots unable to feel, think and express themselves.

On a first look, the society described in "Brave New World" is quite the opposite. Everyone is happy, oppression does not exist, as all the wishes can be fulfilled. The population is drunk with cheap feelings, often not more than physical sensations - yet, what more could they want? Dumbness is cultivated in their minds, depending on their caste, they get a smaller or larger dose of it. In my opinion, the main principle of this society lies in the fact that people are not aware of their existence as individuals, only as part of the whole. This reminds me of the social principles often found in left wing political views, though in this case, in a broader scope.

I also noticed some similarities with our present world, albeit they might be a bit subjective.

Consumerism. An often criticized principle nowadays is also wide spread in the book; the population is "taught" to despise anything that's old and yearn for new. Though I must admit that the book leaves the reader wondering how consumerism gets along with social stability; how can one constantly provide new things, without placing in jeopardy stability?

Cheap sensations. Aren't we taught to appreciate cheap sensations? The chemical taste of colourful commercial products, the beauty of enjoying relationships without involvement, the relief of a pint of beer after a bad day at the office? Of course, some of these are psychological needs, though one might wonder how much they blind us from our inner self.

Television and media. The "civilized" citizens of the new world are dependant on media; not so much on the delivered content, but on the way it shields them from themselves. It's remarkably how in 1932, somebody was able to guess so precisely the anesthetic effect of media nowadays. Television, radio, games - they're all very useful cures against solitude. How often have you turned on the TV, not because you wanted to watch something, but just because you wanted to get rid of the heavy silence?

All in all, I liked the book. There are of course some open questions, and also some passages where I feel there's a too strong emphasis on religion, especially Christianity - without fully dissecting the principles behind it. But if we keep in mind when and where the book was written, it's easy to understand this. I highly recommend the book to anyone that enjoyed 1984 by George Orwell, or who wouldn't mind to experience a dose of futuristic vision of a promiscuous world over-saturated with happiness.

A few quotes that I enjoyed:

"Home, home - a fem small rooms, stiflingly over-inhabited by a man, by a periodically teeming woman, by a rabble of boys and girls of all ages. No air, no space; an under-sterilized prison; darkness, disease, and smells." (Chapter 3)

"But every one belongs to every one else," he concluded, citing the hypnop?dic proverb. (Chapter 3)

[soma] "All the advantages of Christianity and alcohol; none of their defects." ... "Take a holiday from reality whenever you like, and come back without so much as a headache or a mythology."

"One of the principal functions of a friend is to suffer (in a milder and symbolic form) the punishments that we should like, but are unable, to inflict upon our enemies." (Chapter 12)

"And yet," said Helmholtz when, having recovered breath enough to apologize, he had mollified the Savage into listening to his explanations, "I know quite well that one needs ridiculous, mad situations like that; one can't write really well about anything else. Why was that old fellow such a marvellous propaganda technician? Because he had so many insane, excruciating things to get excited about. You've got to be hurt and upset; otherwise you can't think of the really good, penetrating, X-rayish phrases. But fathers and mothers!" He shook his head. "You can't expect me to keep a straight face about fathers and mothers. And who's going to get excited about a boy having a girl or not having her?" (The Savage winced; but Helmholtz, who was staring pensively at the floor, saw nothing.) "No." he concluded, with a sigh, "it won't do. We need some other kind of madness and violence. But what? What? Where can one find it?" He was silent; then, shaking his head, "I don't know," he said at last, "I don't know." (Chapter 12)

"Of course it does. Actual happiness always looks pretty squalid in comparison with the over-compensations for misery. And, of course, stability isn't nearly so spectacular as instability. And being contented has none of the glamour of a good fight against misfortune, none of the picturesqueness of a struggle with temptation, or a fatal overthrow by passion or doubt. Happiness is never grand." (Chapter 16)

"Each one of us, of course," the Controller meditatively continued, "goes through life inside a bottle. But if we happen to be Alphas, our bottles are, relatively speaking, enormous. We should suffer acutely if we were confined in a narrower space. You cannot pour upper-caste champagne-surrogate into lower-caste bottles. (Chapter 16)

"Did you eat something that didn't agree with you?" asked Bernard. The savage nodded. "I ate civilization." (Chapter 18)

Sunday, 14 June 2009

CSS Specificity - Choosing between conflicting attributes

One thing always puzzled me when working with CSS style sheets - how do browsers interpret conflicting attributes?

Certainly the order in which attributes appear in the CSS files and the selectors used play an important role - but isn't there anything more to it?

It seems there is - and on complex projects with large CSS files one can run into problems very easily.

Consider the following example,








Box 1
Box 2
Box 3








What color is does "Box 3" have?

On a first look, one would be tempted to say 'blue' - but that's not exactly right. While the colour blue is defined after all other properties, it still doesn't apply. When resolving conflicting attribute declarations, the order is not the only one used.

I had a look over the CSS specifications and I came across this interesting paragraph:


3.2 Cascading order

Conflicting rules are intrinsic to the CSS mechanism. To find the value for an element/property combination, the following algorithm must be followed:

1. Find all declarations that apply to the element/property in question. Declarations apply if the selector matches the element in question. If no declarations apply, the inherited value is used. If there is no inherited value (this is the case for the 'HTML' element and for properties that do not inherit), the initial value is used.
2. Sort the declarations by explicit weight: declarations marked '!important' carry more weight than unmarked (normal) declarations.
3. Sort by origin: the author's style sheets override the reader's style sheet which override the UA's default values. An imported style sheet has the same origin as the style sheet from which it is imported.
4. Sort by specificity of selector: more specific selectors will override more general ones. To find the specificity, count the number of ID attributes in the selector (a), the number of CLASS attributes in the selector (b), and the number of tag names in the selector (c). Concatenating the three numbers (in a number system with a large base) gives the specificity. Some examples:

LI {...} /* a=0 b=0 c=1 -> specificity = 1 */
UL LI {...} /* a=0 b=0 c=2 -> specificity = 2 */
UL OL LI {...} /* a=0 b=0 c=3 -> specificity = 3 */
LI.red {...} /* a=0 b=1 c=1 -> specificity = 11 */
UL OL LI.red {...} /* a=0 b=1 c=3 -> specificity = 13 */
#x34y {...} /* a=1 b=0 c=0 -> specificity = 100 */

Pseudo-elements and pseudo-classes are counted as normal elements and classes, respectively.
5. Sort by order specified: if two rules have the same weight, the latter specified wins. Rules in imported style sheets are considered to be before any rules in the style sheet itself.


Thus, in our case, the confusion is caused by different specificity levels. While sometimes specifity might seem natural (e.g. selecting elements by ID), other times it can lead to confusion. I think the above five rules play a very important role - too bad that most CSS guides and tutorials don't mention these bits.

Wednesday, 20 May 2009

Setting up Emacs on Windows

Today I decided to give Emacs another go. I was quite decided to stick with Vim, until I ran into a few XML formatting issues. The XML support is a bit limited and unfortunately it's not the only one on the list. I still think it's a great editor and knowing a few shortcuts always saves the day - and it's also deployed by default on all Unix like machines.

Emacs does have a few limitations too - in fact, they were probably the reason why I gave up to it a few times in the past. Lack of real word wrapping and a very complicated mechanism for using character encodings are my main annoyings - but hopefully I'll overcome them - somehow.

The first one on the list, is the installation on a Windows machine. I won't describe why it has to work on a Windows machine, since we don't live in a perfect world and things should work as they are.

First, let's get the binaries from the official site. We don't want to complicate our lives more than necessarily, so let's pick the precompiled distribution.

The second step is quite obvious - extract the zip file somewhere on the filesystem.

Now we should be able to start up Emacs by running runemacs. I highligy recommend adding the Emacs bin directory to the system PATH. In addition, the following environment variables should also be set:

  • HOME

    This one is inherited from the Unix system, where it points to the "home" folder of the current user. On a Windows machine, this is a bit different - though judging from the current trends, it could be "C:\Documents and Settings\USERNAME" (or "C:\Users\USERNAME" for Vista). It doesn't really matter what folder you use, but keep in mind that other software designed for Unix systems might pick this setting up and use it as a default save location.

  • ALTERNATE_EDITOR

    You should set this to "runemacs.exe". The value defined here will be picked by the emacsclient utility. Failing to set this variable will cause "emacsclientw" to report the error: "No socket or alternate editor."

  • EMACS_SERVER_FILE

    Another setting required by the emacsclient utility. By default, it should point to %HOME%/.emacs/server - the location where the server file resides (this file is used to detected the Emacs server running in the background).



It is recommended to define these environment variables per user. On Windows Vista, you can do something like this:

setx ALTERNATE_EDITOR runemacs
setx EMACS_SERVER_FILE ...


You can open files in Emacs in two modes:

  • open a new instance of Emacs for each file

  • open a single Emacs instance with multiple buffers (or windows)



I prefer the second approach, since it's faster and allows you to use Emacs in a more compact mode (without too much interference with the operating system). In order to use this mode, you need to start emacs with "emacsclientw.exe filename". This will check if there is an Emacs instance running in the background and it will use it. Otherwise it will just open a new instance.

You should have a functional Emacs installation by now. Unfortunately I still get the following error when starting up Emacs for the first time (with no server running): "connect: No connection could be made because the target machine actively refused it." It looks like Emacs is not removing the server file when the server shuts down. Because of this, future instances will attempt to connect to the host and port defined in this file - but nobody will listen there. Besides the annoying popup error message, there don't seem to be any other implications.