Martin's technology blog – 5 latest posts

Blog content

Latest posts

Active categories:

More tags ...

By date:

    (No recent posts)

Blog calendar

September 2017
Mo Tu We Th Fr Sa Su
 << Aug Oct >>
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30

Blog features

RSS feed icon RSS feed

RSS comment feed icon RSS comment feed

Fixing GPS tracks chopped up by OpenStreetMap's Potlatch

posted by Martin Rubli at 16:21

The other day, while uploading some GPS tracks to OpenStreetMap, I noticed that Potlatch reproducibly chops up some of my traces into pieces, which makes them quite hard to turn into paths. Here's an example of an affected track:

Apparently I wasn't the only one with this problem, but with a fix - or even a proper explanation - outstanding, I did a little investigation.

The good news: The gaps in the track don't stand for lost points but for long straight lines. Therefore the easiest fix is to simply convert all track parts into paths and connect their ends. If your track is short or is only cut up into a small number of pieces that works great.

The better news: There's a batch processing solution for it, which works great for longer and more heavily chopped up tracks. Not surprisingly the solution involves GPSBabel.

I didn't spend much time on finding the optimum value, but a quick inspection suggested that Potlatch was cutting up the track between points that were more than about 100 m apart. With GPSBabel's interpolation filter it's an easy task to interpolate points whose distance is less than that:

gpsbabel -i gpx -f chopped.gpx -x interpolate,distance=0.095k -o gpx -F fixed.gpx

And there you go, the fixed track looks just the way it should:

Of course, now that you know the problem you can also tune the settings on your GPS device to make sure the logging interval is low enough. That way at least your future tracks won't cause you the same headaches. Happy mapping!


Generating OATH OTPs on Windows with oathtool

posted by Martin Rubli at 14:39

While Google's Android market and Apple's App Store are full with little apps that can generate OATH one-time-passwords, finding something similar for Windows proved to be quite a challenge.

The only free one I came across is OathToken for PC, a very simple tool that unfortunately insists on generating its own secret.

If you're looking for something a little more flexible your best shot may be running the original oathtool from the OATH Toolkit.

The quickest way to get it running is to download the sources and build them from scratch using Cygwin, which is refreshingly painless.

Of course, with security related software, you shouldn't trust anything you haven't built yourself, but for those of you who choose convenience over security I'm providing the compiled 1.10.0 version here for download. You have my personal promise that I didn't tamper with the sources - I'm far too lazy for that. ;-)

oathtool-1.10.0-cygwin.rar (829 kB)


Querying key states in PowerShell

posted by Martin Rubli at 13:45

Did you ever wonder how to check key states in a PowerShell script? This can be handy in situations where you want your script to behave slightly differently when, for example, the Shift key is pressed.

The first instinct would be to use something like the Windows.Forms.Control.ModifierKeys method, which even works for .NET console applications. However, in PowerShell said method always returns None, so that won't work.

Here's a slightly uglier method that provides a workaround:

function Get-KeyState([uint16]$keyCode)
{
  $signature = '[DllImport("user32.dll")]public static extern short GetKeyState(int nVirtKey);'
  $type = Add-Type -MemberDefinition $signature -Name User32 -Namespace GetKeyState -PassThru
  return [bool]($type::GetKeyState($keyCode) -band 0x80)
}

The function can be used as follows:

$VK_SHIFT = 0x10
Write-Host "Shift key pressed:" (Get-KeyState($VK_SHIFT))

For more information on how to query other keys you can consult the documentation on the GetKeyState() function and Virtual Key Codes.


SetPoint 6 and the discrimination of the ambidextrous

posted by Martin Rubli at 15:44

Plagued by constant trouble with my Logitech mice I recently decided to check for a new version of the infamous SetPoint (infamousness is inheritable). Having been using SetPoint 4.8 I was pleasantly surprised at the double major version jump - despite longstanding experience that new versions hardly ever deliver a net benefit. Maybe it's the profession of software engineering where "this bug is fixed in the latest version" is not only an illusion but the safeguard of your paycheck. But I digress ... Let's just say I was enthusiastically optimistic.

Both my enthusiasm and my optimism were reinforced when my Cordless Optical TrackMan, for which I was already applying for a South European citizenship (you know, because of how often they strike ...), suddenly started working again. The setup program promising to do away with the annoying-to-death and premature battery warnings, and the user interface looking cleaner and feeling less sluggish was just the icing on the cake.

Understandably enthusiastic (and optimistic) I started redoing my settings and soon started noticed that an elementary feature had died the feared death through ominous marketing decisions; the little check box to switch the left and right mouse buttons on a device-by-device basis. The only way to swap the buttons now was Windows' own control panel dialog, which, just as ominously, affects all the mice connected to the system.

"What's the big deal? How many mice do you need for one computer?" you say? The answer is at least two if you're ambidextrous or suffer from mouse overuse syndrome (and at least three if you count the one on the sofa for when you hook up your PC to the TV).

Slightly less enthusiastic (but still optimistic) I decided to e-mail Logitech customer support. I had heard lots of good things about them, plus it's educational to use your own company's customer support, so you can see it the way ordinary customers do.

It only took a few hours to get a response. The friendly support guy told me that he had also failed to accomplish what I was trying to do and that the only solution was to downgrade to SetPoint 4.8; not exactly what I had in mind.

I don't give up easily though. I was already contemplating writing an HID filter driver when I thought of uberOptions, a very dedicated and inspiring project that is the rescue of all people who feel that after buying an expensive input device they deserve to do with its buttons what they want.

Even though SetPoint 6 is not officially supported yet it worked great. After a quick installation I finally got my 'Swap buttons' check box back:

Set Point 6 settings dialog with uberOptions

And I clicked happily ever after ...

There's a side story to this one, which is that my MX Revolution mouse recently started refusing to charge, which seems to be a common problem. Luckily, for now, I haven't had to use the soldering iron. Instead, cleaning all the charging contacts and taking out and replacing the very same battery (easy to do; the four screws are under the little rubber pads) seems to have helped.

So, in just a few days I went from having two expensive designer paper weights on my desk back to my proven "2 Logitech mice + 1 Microsoft keyboard" sandwich.

PS: I was trying to find some statistics to confirm my conviction that the French, Italian, Spain, and Greek without a doubt must lead the strike statistics only to be heavily disappointed by the real numbers. But, as one of my friends likes to say, don't let the truth get in the way of a good story. :-)


How not to enable fuzzy string matching in Postgres

posted by Martin Rubli at 14:23

I have ranted previously about people not being able to read attentively when they're trying to solve problems. Here's another one:

A few years ago I helped teach a class on information systems, namely I was in charge of the fun part - a project where students had to write their own web application.

Because lack of documentation was always the part that bugged me most about projects when I was a student myself I spent a great amount of time writing the project material and how-to guides for the software we were using. After the class I mirrored the material on my own website. (Yes, I'm proud of the project being a success.)

Now, for some reason one of the how-tos shows up quite high if you search Google for words like "postgres fuzzy string matching". At one point it tells students:

[...] if you want to use these functions in your database please send a quick e-mail to Martin so we can activate it for your databases.

And they do! Today is the second time I got an e-mail from some random person (this time a student, last time a post-graduate!) asking me to please enable fuzzy string matching in their database. It looks something like this:

Dear Mr Martin Rubli,
I want to use fuzzy string matching in my database. Can you activate it for my database ?.
I hope to hear from you soon. Thank you.

There are several things that strike me here. The first one is that it should be pretty clear from both the URL and some of the text that this is class material, not some generic tutorial. Then, why do those people think I'm running a charitable Postgres fuzzy string matching activation service instead of just posting the simple instructions on my website? And finally, let's assume I had such a magic service, am I supposed to guess the server addresses and the access data?

I think the message is clear here: If you want me to enable fuzzy string matching in your Postgres database, for god's sake include some IP addresses and credentials, so that I can have some fun with them! :-)


1 2 | Next »