Lame Mr Linkedin

linkedin iconI have been procrastinating on an update to my CV, so I was very surprised when my wife congratulated me early today because I was finally doing it. After disabusing her of her idea, I asked why she had figured that out. and the guilty part was..... LinkedIn.

Yes, she is part -incorrectly- of my professional network, and had received one of those weekly LinkedIn mails reporting updates on her network. And my name appeared there: "LuisM Pena has added skills: C#, SOA, Distributed Systems, and 5 more"

In fact, all the skills were correct, but I had entered them all at once, a few years ago; I hadn't updated anything at all in the past days -even in the past months-. so I guess this is the way that LinkedIn uses to spur your curiosity, check profiles and keep the networking that is essential for LinkedIn operations: lame, Mr. LinkedIn, very lame

TableFilter v5.1.1

table filter iconNew release for this Java library, solving a minor issue, but requiring updating the API

Autocounters in Django ORM

django iconFighting today in Django ORM, how to use a typical autocounter. Let's say we have a database table with two columns called name and value, being name the primary key. The idea is to be able to increment the value associated to a key, that will be used for some external purpose(s). As the Django documentation mentions, this implies a solution such as:

product = Product.objects.get(name='Venezuelan Beaver Cheese')
product.number_sold += 1

And the same documentation shows the race condition problem: two thread or processes could perform the same operation, resulting in the counter being increased only once. The Django ORM solution makes use of F() expressions:

from django.db.models import F
product = Product.objects.get(name='Venezuelan Beaver Cheese')
product.number_sold = F('number_sold') + 1

With this code, the counter is effectively robust and better performant. The problem is, how to get hold on the incremented value? It is needed to reload the object to access the actual value:

sold = Products.objects.get(

Which brings back the original race condition in a different way: now, two simultaneous processes would effectively increase twice the counter, but both could get the same counter value!

This is not a problem of Django, but of the underlying database, and F() expressions can still be helpful if the counter's value is not required. If this is not the case, trying to overcome the counter problem using exclusively the Django ORM approach is an invitation to lose a few hours testing all possible approaches :-(

More sqlite3 tables alterations

database iconDuring a current migration of a project to Django, I wanted to make explicit the usage of a primary key on a table that lacked it (using the default rowid column instead).

My previous release of alter_table did not support renaming the rowid column, so I have released a new version (0.20) with this support. Adding some more functionality, the utility also supports now reordering columns in tables.

Altering sqlite3 tables

database iconsqlite3 does not support some basic SQL operations, more specially dropping or renaming columns.

alter_table is a python utility that supports specifically these two operations. It modifies the tables and any related indexes; however, if there are views or triggers depending on the altered tables, the user must recreate them.

PI day!

brain puzzles iconStumbled by mistake on a wikihow page about How to Celebrate Pi Day. No words to describe it.

Fortunately, I also stumbled on this page on Epigrams on Programming, by Alan J. Perlis. Some jewels, in the order they appear:

  • [11]: If you have a procedure with 10 parameters, you probably missed some.
  • [19]: A language that doesn't affect the way you think about programming, is not worth knowing.
  • [40]: There are two ways to write error-free programs; only the third one works.
  • [98]: In computing, the mean time to failure keeps getting shorter.

And, just for fun:

  • [110]: Editing is a rewording activity.

TableFilter v5.0.0

table filter iconI just released a new version for table filter, a library to enable Excel-like filtering on Swing tables.

Although the functionality changes are rather minor -basically affecting the sorting order of choices-, it had quite a large impact on the implementation. However, the main reason for a major version change (from 4.5.0 to 5.0.0) is because the support for Java 5 is finally dropped. Java 5 always lacked the required functionality to support table filtering, so a lot of code had to be maintained to provide that support. And that work is now difficult to justify: mind you, Java 5 entered its end-of-life on April 8, 2008 and is no longer supported since November 3, 2009.

So, good riddance, to the Java 5 support!

Playing with OpenWRT

router iconI bought a cheap router, a TPLink 841N, for the explicit sake of installing OpenWRT and playing with it (which originated in the unfulfilled wish to setup a SSH tunnel on my existing Netgear router with the existing official firmware).

My main objective is very simple: I have hosts on several locations, where I run OpenVPN, and I would like to automatically being able to appear as having an IP address on those hosts. That is, by connecting to specific ports on my router, all my network traffic will appear as originating in one of those hosts.

So far, I have succeeded at setting up correctly the wired ports, and I hope to have ready the wireless connections sometime soon.