Archive for June, 2008

Validate GPX file in Linux

Monday, June 30th, 2008

The website describing the GPX standard describes a way to validate your GPX file in windows, however it does not mention a way to do it in Linux. So heres how you can validate your files (one way of many, I’m sure). The program you use is called xmllint, and in ubuntu, the package that contains this is libxml2-utils …

GPX 1.0:

xmllint --noout --schema http://www.topografix.com/GPX/1/0/gpx.xsd testfile.gpx

GPX 1.1:

xmllint --noout --schema http://www.topografix.com/GPX/1/1/gpx.xsd testfile.gpx

Hope that saves you some time!

The Answer to Infinite Loops

Sunday, June 29th, 2008

Programmers, we should make our infinite loops more exciting! A lot of times in C or other languages, you see infinite loops represented by things such as

while (1) { /* do stuff here */ }

Or perhaps by

for (;;) { /* do stuff here */ }

Thats so boring! Why not be more creative in your work? I propose that we use the following construct instead

while (42) { /* do stuff here */ }

Now you might ask, why use while() instead of for() or do.. while()? In my opinion, its cleaner (the while part, not necessarily the number part). while() seems like the correct options, since (in my mind, at least) for() implies some set amount of iteration, whereas while() implies keep going until some condition is false. Of course, I do realize that they all do the same thing and each different one can do the same things as the others with some modification.

Yes, that was a rather useless post, but I had to get it off of my chest 🙂