Category Archives: nerd

File associations

Today I double clicked on a CSV file on my Mac, and I proceeded to watch the Excel icon bounce up and down in my dock for about 15 minutes while it churned on the document.  I was then presented with a spreadsheet with all of the data contained in one column.  Excel had blown it.  I was upset.  I hate Microsoft Office, and it totally sucks.  I don’t want it to defile my computer with its presence unless circumstances are dire.  But, it has asserted to the operating system its great ability to open CSV files.  Unfortunately, that ability is limited to the “import” function in the file menu, and it is not smart enough to perform an import when it overconfidently attempts to open a file through the Finder.  This led me to reflect on the annoying feature that is file associations (or whatever your platform chooses to call them).

File associations have always been annoying.  Programs fight over them and they always end up being what you don’t want, but changing them to what you do want is a giant farkle festival that would only be enjoyable to the most serious nerds.  So, in my frustration I came up with an idea.  Programs should be registered according to their ability as well as their “goodness” at opening files.  For example, Microsoft Office’s ability to open a docx file might be 9/10, whereas OpenOffice would be like 5/10.  In this case, when a user clicks on a docx file, the computer decides to go with Microsoft Office.

Obviously, overconfident software vendors like Microsoft and Adobe would always set their values to 10/10 for every file time.  That’s where the power of the Internet comes in.  A community based web site could be created to rate the abilities of programs to open files.  Maybe on a spectrum of different characteristics (correctness, annoyingness, memory hogging, etc.).

Advertisements

Cisco AnyConnect with Ubuntu server

Cisco has a VPN client called AnyConnect which is used with its SSL VPN products. I don’t know that much about the details of their product line, but I happened to be attempting to use it in a weird situation and ran into some trouble. I’m running an Ubuntu server AMI on Amazon EC2, so it’s a quite minimal install. It seems that pretty much every error with the program comes up as the following:

>> error: Connection attempt has failed due to server certificate problem.

In my case, there were several issues. First of all, it requires several shared libraries. If you run the following, it should take care of all of the shared library requirements missing in the default install:

$ sudo apt-get install libnss3-1d

Next, it actually expects Firefox to be installed, because it apparently messes around with the firefox config store. I installed Firefox to no avail (which downloaded about 300 MB of packages), so I will save you the time and let you know that that was both unnecessary and useless to solve the problem. All you need is a Firefox profile for it to stick some new cert info in. This command (executed from the user’s home dir) should do the trick:

$ mkdir -p .mozilla/firefox/anything.default

And one more thing to mention, various forum posts I saw mentioned not to run the “vpn” program (used to manage the VPN state) as root. So, I ran it as my normal user.

Once I did all of that, everything worked great. Cool.

Apache Commons

If you are a Java developer, and you don’t know about Apache Commons, you should take a minute to check it out.  A lot of times when you need to write some mundane code to do something, and you are thinking to yourself, “I’m sure a million other people have had to write this code”, you should take a quick look at commons to see if they did it.  A lot of times they have it packaged up in a nice library.  One of my favorites is the IOUtils class in commons-io, which can pull an InputStream into a String object in one line of code, but they have a bunch of other stuff that is useful as well.

Deleting SQLite database in android

If you are in the process of developing an android app that uses SQLite, you probably have found yourself in the situation where you wanted to restructure the database.  Instead of bumping the version on the helper class and putting in upgrade logic, it is best to just start over with a fresh database when you haven’t yet released your new version of the app.  Here’s how you zap your database in the emulator’s file system.

First, find out the serial number of the emulator as it is running:

$ adb devices
List of devices attached
emulator-5554    device

Now, connect a shell and delete the file from the filesystem:

$ adb emulator-5554 shell
# rm /data/data/<yourpackage>/databases/<databaseName>
# exit

After that, your database should be gone and will be recreated next time you run the helper to get a connection.

Spring JDBC is awesome

I would like to just take a moment to express my love for Spring JDBC. I just deleted giant swaths of database connection handling code from an app I’m maintaining by replacing a DAO with a Spring JDBC version. If you haven’t taken the time to learn about it, check it out here.

Moving code from one SVN to another

I am currently working on merging some of the projects from two different SVN repositories to one repository. I don’t want to do a full dump of one and restore to the other, because the organization is a bit different in each. The solution is something like this:

  1. Dump the entire source repository
  2. Use svndumpfilter to split the dump into separate files
  3. Import each file separately into the right spot in the target repository

Here’s a couple one-liners to split the dump file (I love Unix):

$ cat source_repo.dump |grep -a ^Node-path: | grep -v / |uniq | sed “s/Node-path: //g” > projectlist.txt
$ for i in `cat projectlist.txt`; do cat svn_oasis.dump | svndumpfilter include $i > $i.dump; done

The first command creates a list of top level directories, and the second does the splitting. Now, you have a separate dump file for each different top level directory in the source repo. This can be tweaked if you want to split it based on different criteria.

Once you have the dump file for a project and you want to import it, you use a command like this:

cat project.dump | svnadmin load /usr/local/svn/myrepo

Make sure that the path you are importing doesn’t exist. I did not make sure, then I think svnadmin imported a bunch of stuff, but was unable to create the top level dir, so it probably left a bunch of orphaned crap in the repo. The load process seems pretty half baked, so be careful 🙂

PHP

Samson pointed out this PHP bug report to me:

http://bugs.php.net/bug.php?id=50696

It is an entertaining read. This illustrates a couple of problems with PHP that make me wary of using it for anything too serious. They seem to have a flagrant disregard for specification of their API, as well as backward compatibility. Additionally, the lack of strong typing appears to be the source of all of their issues. I’m not going to say weak typing is bad, I just find strong typing forces the programmer to resolve issues at compile time instead of at runtime (i.e. before the end user is actually running the code and the app blows up on them).

All of this culminates into this bug report, which erupts into a flame war, uncovering the underlying big egos that have probably led to the feeling that strict specification is unnecessary and developers can just “deal with” changes in the API in minor releases. Both of the PHP developers involved in the conversation were extremely unprofessional and resorted to such tactics as name dropping to argue their case.

It sucks, because I think PHP would be pretty nice if they were just a little more strict and professional about these things (both the technical and personal issues).