Looking for freelance projects

September 26th, 2008

I’m available. Yeah, in that sense too, but that’s a point for another post (or another blog). Right now I’m just looking for some good old freelance work.

Testuff is finally in production. The year and a half It took us to get here passed in an instant, and now the beta is over and we’re ready to charge some greens for what we’re doing. However, until sales get enough momentum to support our (not so) lavish lifestyle, we’re all still doing side projects to cover our expenses.

A good friend of mine once said that when you’re doing freelance work of any kind, you either don’t have time to eat or don’t have anything to eat. Looks like he was right, too. For quite a while there were more project offers than I could handle and had to turn people away. Now, on the other hand, things seems to have slowed down quite a bit.

I have 10 years of development experience ranging from C and C++ to Java, .NET and Python. I’m especially interested in projects involving the integration of multiple technologies that were never meant to work together and desktop applications that need stunning UI.

Specifically, if you have a web site and need a great looking desktop application companion for it, let me know.

Please contact me via email at gooli@testuff.com.

My LinkedIn profile is available at http://www.linkedin.com/in/eligolovinsky.

Unicode and permalinks

September 22nd, 2008

Working on integrating of automation scripts with Testuff, I’ve encountered an interesting Unicode-related issue I’d like to share.

The integration allows for an automated testing script to report the results of its run to the Testuff server. In order for the results to be grouped, displayed and summarized correctly, the automation script needs to tell the server which test it ran, and whether the test has passed or failed. A long discussion emerged on what the best way to uniquely identify tests.

After quite a bit of back and forth, we’ve settled on permalinks, those more-or-less-readable URLs that are in common use in blogs. The idea of a permalink is to take the title (of a blog post or a test) and replace any characters that aren’t numbers or letters with an underscore or a hyphen. Using this simple scheme, “Unicode and permalinks” becomes “unicode-and-permalinks”, which is quite suitable for use in a URL.

The implementation is a simple regular expression:

def to_permalink(string):
    return re.sub("[^a-zA-Z0-9]+", "_", string).lower()

While this code works perfectly for the English language, it doesn’t work at all if string is a Unicode string containing something in Hebrew, Russian or Polish - language that some of our customers use. And so, I set out to write code that will essentially behave like the regular expression above, but will work for letters and numbers in all the languages of the world.

Fortunately the Unicode standard includes a rarely used classification of characters into various categories. For each given character we can find out whether it is an uppercase letter, a lowercase letter, and number, a punctuation mark and so on. Surprisingly, Python includes a module called unicodedata that contains all that information. The function category accepts a character and returns a string that tells us what the character is: “Lu” denotes an uppercase letter, “Nd” denotes a decimal digit, etc.

All that remains to be done is go over the characters in the title, keep the letters and numbers, and replace all the other characters with a dash or an underscore. The regular expression at the end replaces any sequence of underscores into a single underscore to make the resulting URLs even nicer to look at.

def to_permalink(s):
    """
    Converts sequences of characters that aren’t letters or numbers
    to a single underscore to achieve wikpedia like unicode URLs.
    "
""
    import re
    import unicodedata
    def conv(c):
        if unicodedata.category(c)[0] in ["L", "N"]:
            return c
        else:
            return "_"
    s2 = "".join([conv(c) for c in s])
    return re.sub("_+", "_", s2)

[Update] Or, as Almad correctly pointed out, you could just use the re module support for Unicode and be done with it in two lines, which kind of takes the air out of this post.

def to_permalink(s):
    import re
    return re.compile("\W+", re.UNICODE).sub("_", s)

There’s one other thing to consider when dealing with Unicode permalinks. If you’re a native speaker of a language other than English, you’ve probably seen URLs that in your own language in Wikipedia.

From the looks of it, URLs can include characters in any language. Right?

Wrong.

RFC3986 defines the syntax for URLs (actually URIs, but that’s a moot point) explicitly and states which characters are allowed in a URL. This includes little more than English letters and numbers from the lower half of the ASCII chart.

If you look at the headers your browser passes when you access such a URL, you’ll see that it encodes all the characters with percent encoding, so neither the browser nor the web server is violating the standard. This is what the server saw when I navigated to the main Hebrew page of Wikipedia:

GET /wiki/%D7%A2%D7%9E%D7%95%D7%93_%D7%A8%D7%90%D7%A9%D7%99 HTTP/1.1
Host: he.wikipedia.org

In order to understand what this percent encoding means, you need to know a bit about Unicode. Basically, the Unicode URL is encoded in UTF8 and each byte of the UTF8-encoded string is encoded using percent encoding. The browser apparently recognized this specific encoding scheme (which isn’t documented anywhere I could fine) and displays nice internationalized URLs for the user.

If you want to support such URLs in your server, you’ll probably need to write some code to translate the percent-encoded URLs into their actual Unicode representation.

Solution for Edimax router BR-6204WG being slow

August 31st, 2008

This message is for anybody who has recently bought the aforementioned router and is experiencing a slow connection and many timeouts. This affects the routers that have the 1.57 version of the firmware installed.

To check the firmware version, go to http://192.168.2.1 (that’s the IP of the router in its default configuration) and click Status Info at the top of the page that appears. The firmware version is written under Runtime Code Version.

The 1.57 version apparently has a bug, which did not exist in previous versions and has been fixed in newer ones. The latest official firmware release is 1.51, and can be found at the Edimax site. I’ve also found a 1.58 version on an Israeli’s dealer’s site here.

Direct link to 1.51 (edimax.com): BR6204Wg_1.51.zip (unzip it before upgrading)
Direct link to 1.58 (pikok.co.il): EdiEngBR6204Wg_1.58.bin

I’ve tested both 1.51 and 1.58, and they both fix the problem.

Upgrading the firmware is actually quite easy.

Go to http://192.168.2.1, select System Tools at the top, then Firmware Upgrade on the left and follow the instructions on the screen.

Hope this helps somebody someday.

Disable scroll wheel clicking in Firefox

August 14th, 2008

I have one of those Microsoft mice here at work and its wheel is quite
light to the touch. It is so light in fact, that I often click it while
scrolling. By default, clicking the scroll wheel in Firefox puts it
into scrolling mode, showing this icon:

Now when you move the mouse up and down, the page will scroll.

That is so annoying!

It took me over 20 minutes of Googling to find how to disable that feature, so I’m documenting it here.

The option that controls it in Firefox is Tools > Options > Advanced > General > Browsing > Use autoscrolling.

Apparently “auto scrolling” is the name of this obscure feature, which is now forever disabled on all my machines.

Accessing SVN revision via a browser

August 10th, 2008

Most people who use Subversion know that you can access the repository with your browser to get a readonly interface that you can use to take a cursory look at the files in there.

This is how the Python repository looks like via http://svn.python.org/projects/python:

It says Revision 65620 at the top and I’ve always wondered if you could access another revision in the same simple way. Turns out there is a way.

All you need to do is add !svn/bc/REVISION to the URL:

http://svn.python.org/projects/!svn/bc/5000/python shows revision 5000 of the Python Subversion repository.

Wrong keyboard layout

May 26th, 2008

How many times have you typed an entire URL looking at your keyboard only to lift your eyes and see that you’ve used the wrong keyboard layout? How many times have you typed your email into some obscure form on the internet only to find that you’ve typed some unintelligible gibberish in Hebrew, Russian or Farsi?

Well, no more! Recaps, that tiny utility that lets you switch your keyboard layout using the almost forgotten Capslock key, can now fix text you’ve typed with the wrong language selected. Just hit Ctrl-Capslock as soon as you discover your mistake and the text will be replaced with what you actually intended to type. I’ve only tested it with Hebrew and Russian, the languages I personally use on a regular basis, but it should work with any language supported by Windows. Let me know if it doesn’t.