VCard phone number normalizer

Comments

These days, it’s no longer good enough to use local phone number formats for your address book; you might be trying to dial someone via SIP without any clear locale information, for example, and so trying to dial a 10-digit US number might end up routing the call to some other country, which can be quite embarrassing.

Further, in this day and age, you might actually be travelling between different countries, and so you can’t really predict what your outgoing call routing will be like!

So, here’s a really simple C++ program that wraps libphonenumber to normalize the phone numbers in a .vcf file (used by most modern address book systems) based on your current locale. It can be used both on local .vcf stores as well as ones stored on a CardDAV/CalDAV server.

See the code comments for usage details.

Exceptions vs. error returns, quantified

Comments

Today I got into a discussion regarding embedded programmers and their tendency to avoid exceptions in C++ (even after moving to new-school “embedded” systems such as smartphones, game consoles, and set-top boxes). The argument basically boils down to three things: code size, memory usage, and execution speed. So, rather than continue on without actually putting my beliefs to the test (the discussion basically centered around whether engineers are making assumptions based on how things were 15+ years ago), I decided to construct a minimal test which I think shows where the tradeoffs may be.

Note: The timing and memory analysis has been updated as of May 24, 2018.

Read more…

Affine HSV color manipulation

Comments

Because the need for color manipulation comes up fairly often in computer graphics, particularly transformations of hue, saturation, and value, and because some of this math is a bit tricky, here’s how to do HSV color transforms on RGB data using simple matrix operations.

Note: This isn’t about converting between RGB and HSV; this is only about applying an HSV-space modification to an RGB value and getting another RGB value out. There is no affine transformation to convert between RGB and HSV, as there is not a linear mapping between the two.

Read more…

xmousekeys

Comments

This is a simple program for moving the mouse cursor around from a script. Useful as something to bind to a key event in window managers which allow such a thing but don’t have built-in keyboard-mouse functionality (such as pwm).

xmousekeys.c