Archive for the ‘Uncategorized’ Category.

Batch Convert Tabs to Spaces

Today I was faced with the problem of trying to review a bunch of Python files which mixed tabs and spaces for indentation. It was so bad it was practically impossible to follow the logic in some cases. I could have changed my editor settings temporarily, but what really needed to be done was change all the tabs into spaces.

Many editors can easily change tabs into spaces, but I couldn’t remember there being a command line utility that would do this.

I figured now would be a good time to get acquainted with ack. I knew I could have found all the files needing to be changed with grep, but given that I was working with a Subversion repository it becomes a bit ugly to filter out the .svn directories. ack does that naturally, and recurses by default too. And I can tell ack to concentrate on just the Python files and forget everything else. This comes out as the following: ack "\t" --python -l.

I then needed to find out how to convert tabs. It turns out there is a small Unix utility just for this purpose: expand.

The final piece was tying these together on the command line: for i in `ack "\t" --python -l`; do expand $i >$i.tmp && mv $i.tmp $i; done.

The inspiration to all this came from this JJ’s post.

Immersed in Books

Whenever I start in a new job, or switch to a new area of responsibility in a company, I end up going over several months of intense reading on new subject matter. This time has been no exception. This kind of tends to burn out my desire to read books for a while unfortunately, so I am trying to slow my intake a little bit this time in the hopes that I can actually build up a sustainable pace of reading new books related to software engineering and work life in general.

This is also only the second time around that I am actually reading several books at the same time. Previously I just finished a book and didn’t start the next until I was done with the previous. But I find that I just thoroughly enjoy some books while some others are hard to digest for one reason or another. So when I notice I am reading something that doesn’t really interest me much (but which I know I will need in my work anyway) I also start another book which I just can’t seem to put down. Makes things more interesting, and hope I can also read through more books faster.

Elements of User Experience by Jesse James Garret was recommended by my boss who has user interface background. I have done very little reading in the user interface area before (and one could argue the few UIs I have created reflect that), so I found this book a good way to quickly get me up to speed on some terminology, how web UI design is different from desktop UI design, and how you can break UI design into different activities and sort of get a blueprint on how to approach the whole UI design challenge. It was a short, easy read, although at times it felt like I was reading marketing material.

I bought Effective Java by Joshua Bloch because I really enjoyed the Effective C++ series by Scott Meyers. I think every language should have a book written in the “effective series” style. I sure wish there was one for Python. The cookbook series comes perhaps closest. Part of the material in Effective Java is going over my head, since I don’t really know Java so well as for this to be useful. I am also finding some things that are applicable to other programming languages as well, which I found kind of surprising given that the Effective C++ series are really tightly coupled with C++ and very rarely is the advice usable in other languages.

Besides Effective Java I also skimmed through the online version of Thinking in Enterpise Java by Bruce Eckel, and I am also skimming through Thinking in Java, 3rd Ed. by the same author. I found Eckel’s style a bit dry, and there is a LOT of material to read, so I resorted to going through stuff pretty fast. Nevertheless, Thinking in Enterprise Java explained a lot of things to me about how to do WEB programming in Java, and there have a been a few useful bits of information in the first six chapters of Thinking in Java as well. I also appreciate the way Eckel writes his book in a kind of Open Source way.

I am also working on a Hyperic UI plugin, where I am using Groovy. There was a quote which summed up Groovy pretty nicely; unfortunately I can’t find the quote right now but it went something like this: “Groovy: they way Java was supposed to be.” For a Pythonista there is a lot to like (read: not too different from Python). I bought Groovy Recipes by Scott Davis to jump start me on Groovy. So far I haven’t been too impressed; some of the recipes I have checked seemed too much simplified to be useful. But I bought the book mainly for language introduction, and I guess I was also partly persuaded by the section on Eclipse integration.

I bought one book at CommunityOne (they had a nice discount): The Pragmatic Programmer by Andrew Hunt and David Thomas. The title alone made me like the book, as I think I have become more pragmatic (as opposed to idealistic) over time. But it turned out that wasn’t exactly what the book was about; it is more about becoming a better programmer (rather than pragmatic). I just started the book, so I can’t comment much on it at this point. But there is one piece (already, oops) that I kind of disagree with the authors. The “Don’t Live with Broken Windows” tip, meaning you should fix bad design, code etc. as soon as you see it. They do amend that tip by saying you should at least do something to amend the situation if you don’t have the time to fix it correctly right away. I very briefly tried to do this early in my career and found I got hardly anything done as I was fixing things left and right as soon as I saw them, and quickly forgot what I was actually supposed to be doing. Now I tend to either put in an XXX comment next to the problem spot or file a bug for the issue I noticed and try to retain concentration on the current main task. Perhaps that is enough to fill the spirit of the tip, but I feel it is worth noting that it can also be very distracting and it can slow you down a lot. I feel it is also better to fix one issue per checkin, because this makes it easier to verify fixes and debug and back out bad checkins. (There are tools that help checkin just the pieces you want even if you have been working on multiple issues at the same time, but these are still pretty rare and hard to use.)

Back in January or February I also read MySQL Crash Course by Ben Forta, which I think did a good job of getting me quickly up to speed with MySQL (the only caveat being that I had to go to the book’s website to figure out how to get started with the samples). I just took a quick look at the cover and was surprised that it was from Sams Publishing, which traditionally has done a pretty bad job with technical books. Maybe this book is an indication that they are getting better. Now that I am working with PostgreSQL I feel like I’d need a similar crash course for PostgreSQL.

I also started reading Beginning Database Design by Gavin Powell earlier this year. It has gotten pretty good reviews, but I put it on the back burner for a while and I need to get back to it soon.

Jobhunt

For a while I had been thinking about what I would like to do next, professionally. Most of my career has been writing desktop applications, and besides getting a bit bored at it it is also pretty clear that most applications will live on the web in the future. Another interesting trend (to me at least) are mobile devices. So I spent roughly a month exploring both web application development and mobile application development with personal projects, and then started applying for jobs in earnest.

I don’t have much experience in interviewing for jobs, but it is a skill that can be improved by studying and practicing. I received a bit of formal training back in 2003 which was a big help to familiarize myself with the US way of doing interviews. The biggest help with the technical part of interviews was the book Programming Interviews Exposed, and practicing based on the advice in the book. And of course doing a lot of interviews is important as well, which was why I applied to some positions that I didn’t consider ideal for me but I cast a wider net in the hopes of getting experience interviewing.

Geographically I limited my search mostly to the San Francisco Peninsula from San Jose to San Bruno, and positions that were offered with 100% telecommuting option. I was also more interested in smaller companies. I found most of the job postings on Craigslist. I did not use services like Dice or Monster.

I applied at 22 companies. 11 positions were mostly web development, 6 positions mostly mobile development, 2 positions hybrid and 2 other positions. I never heard back from half of them. One said they would get back to me and never did. One I had to abandon because they were too early for me at the moment. One I had to abandon because I had already received offers and needed to give my answers before being able to finish with the ongoing interviews. One company informed me they did not have a suitable position now but to check back in a few months. In one interview I realized the company was looking for a different person than they had the position description for. I realized in one phone screen that the company wasn’t right for me. Of the remaining 5, I did badly in two phone screens: one was an algorithm question in a problem area I had never thought about with huge datasets that I don’t have experience with (relevant to the company and position, though) and in the other phone screen the interviewer was mostly interested in seeing how I would optimize an internet connection which seemed kind of strange and I apparently didn’t come up with enough convincing ideas. I locked up in one face-to-face interview during an algorithm question (note to self: never interview last thing Friday evening) and the remaining two lead to offers.

It is kind of interesting to note that I had some sort of “insider connections” to 12 of the companies, which may have helped me get some interviews arranged. As far as I know it did not play a role with the company that I accepted the offer from, though.

When I compare my job hunt now to what it was in 2003 things were dramatically different. There were a lot more jobs available now, for one. I had more marketable experience this time. I wasn’t in any particular hurry this time. I had also more experience being a hiring manager myself. There was also a big difference in the quality of interviews that I went to this time. Almost all companies asked algorithm questions, and most were reasonably good questions at that. Back in 2003 the questions were much more scattered. One company used an automated online programming task system like Topcoder. One phone screener asked me to go to a certain URL and explain what was wrong with some programming samples. Nothing like this happened in 2003. It seems like there could be market for some company to provide a system similar to Topcoder to companies who want to ask coding questions. On the other hand, the interaction between the interviewer and interviewee is also really important, so I don’t think it would be a good idea to replace the face-to-face time with an automated test.

I had two financially comparable offers for very different companies and positions (both of which I found interesting), which made it very difficult for me to make my decision. In the end I decided for SpikeSource, where I started on March 31, 2008.

Happy 10 Year Birthday Mozilla

March 31, 2008 marked the 10 year anniversary of the Mozilla project. Amazingly I find I have been involved since the first year (although in lesser capacity over the past four years). The reason I got involved in the first place was that the Finnish company Citec I was working for had just learned that its worst competitor had bought the company that made a vital component of Citec’s Multidoc Pro SGML browser and as a result it became unviable to continue with Multidoc Pro as planned. Netscape’s announcement couldn’t have come at a better time.

Johnny Stenback was the first to start hacking on the Mozilla code at Citec, and me and others soon joined and produced the Doczilla superbrowser. Many people asked us how we were able to work with the Mozilla code when most others they had talked to gave up for various reasons. I have always said we had a very specific goal in mind which helped us concentrate on a subset of the Mozilla code, understand it, and extend it. Perhaps we were also too young and inexperienced to understand it was impossible to work with the Mozilla code ;) . Unfortunately Doczilla development stagnated, but Netscape was still going strong so Johnny and I found ourselves at Netscape in the summer of 2000. And the rest is history.

I also was kind of surprised that I actually made it to the party. The place was packed, and it was great to see so many familiar faces, as well as finally meet people with whom I had only exchanged emails (for years in some cases).

R.I.P. the Dungeon Master

Gary Gygax is dead.

I have a hard time time coming up with the words to describe how big an effect Gary Gygax and his work has had on my life. Being into all kinds of games it is perhaps no wonder that eventually I would run into the game created by Gary. A friend introduced me to Dungeons & Dragons when I started high school. I was hooked instantly. There was just something unimaginably cool about the game.

I had been pretty good with English even before then in school, and had read some novels in English, but what really catapulted my interest and skills was starting to play role playing games. There were lots of rule books to read, and eventually there were lots and lots of fantasy novels written that took place in the imaginary worlds my game characters lived in. This thing just fed itself, pretty much.

I also believe that a lot of the skills I use every day as software engineer got honed and improved while playing role playing games. There was a little mathematics involved, probabilities, problem solving, puzzles, detective work and so on. My friends and I even created our own games, and before we found out where to buy unusually shaped dice we made our own dice (of course, probabilities were not quite right;)

All of that helped me get a spot as an exchange student to the UK, where I made friends through the role playing society. And later when I relocated to California, I found my first friends outside of work through role playing games, from the boards of Bay Area Role Playing Society.

I guess one of my unrealized dreams was to visit GenCon one day and thank Gary for his work.

Rest in peace Gary, you will be remembered fondly.

Webmastering for the Finnish Language School of Silicon Valley

I volunteered as webmaster for the Finnish Language School of Silicon Valley non-profit. First I needed to renew the domain, which was just about to expire. I then took a look at the current hosting provider, doteasy.com. They don’t offer a lot, but the hosting is free without banner ads on your site, and you also get an email address. The downside is that they require you to register the domain through them, and this is at least 2-3 times more expensive than domain registrations elsewhere. All in all, not too bad but I thought I could do better.

Since I host at Dreamhost myself and I am reasonably happy with them, I asked if they had discounts for non-profits. Turns out they offer free hosting for non-profits, and I believe this also includes free domain registration. So off I went, faxed the needed documents and finally got email informing me the account was set up.

At first I set up various email addresses (unlimited number available, basically) to manage the site, and created the old contact address as well. I then set up a Subversion repository which automatically pushes changes to the live website, and sends out a commit message to me as well.

Compared to the old setup, Dreamhost offers secure shell access via ssh, unlimited accounts, more disk and bandwith, backups, and overall more tools to manage the site. And with the Subversion setup, any change can be rolled back, rather than relying on daily backups from Dreamhost. Not to mention that the commits list alerts me to any changes (via Subversion at least).

The major issue at this point is finding some free cross-platform WYSIWYG HTML tool(s) that can edit the simple HTML files via WebDAV folders. All major OSes can now mount WebDAV folders, but I was bummed to note that Kompozer does not support WebDAV (it does not even seem to help when a WebDAV folder is mounted). It is also somewhat a hassle to deal with SSL without paying for a dedicated IP and certificate, because what Dreamhost offers for free is created by them; expect warnings about unknown CA and mismatched domains. Better than nothing, I guess.

Now that the infrastructure is in place, including DNS updates, I can concentrate on updating the site content, and eventually migrate the domain registrar to Dreamhost as well.

Update: The non-profit hosting plan actually seems to include some free IPs as well as a free certificate, so I’ll need to take a look at enabling that.

Update2: I found out Seamonkey Composer supports WebDAV upload, so I am all set with open source, cross-platform WYSIWYG HTML editor that I can recommend to my users.

Finnish Localizations

Seems I got in the mood for some localization work after localizing (read: translating) Chandler 0.7.3 into Finnish. The Foxmarks guys share office space with OSAF, and seeing they did not yet have Foxmarks in Finnish I decided to pitch in. There is a really cool site, babelzilla.org, where you can translate Firefox extensions, and it was pretty easy to use. Foxmarks additionally has server side stuff, and for that I received a .po file and translated that with poEdit, which is pretty good. (My major gripe with poEdit at this point is that it does not have Undo.)

To top it all off, I translated some Wikipedia articles starting from the Chandler article.

Update: I also started Finnish translation of TWiki, which is used by OSAF. The translation is only 36% percent complete according to this page, but this will at least easily enable one to translate topics.

Tax Time

Everybody always complains about how much taxes they pay. Finland is typically considered to have a very high tax rate. The US tax rate is much lower than in Finland. I just finished my US taxes, and indeed, the percentages look ridiculously low compared to Finland. However, if I then change my health insurance premium into “tax”, my 401k deductions to “tax” and my son’s college savings deductions to “tax”, I can quickly end up with more than 50% tax! That is more than I would pay in Finland, considering that I would not need to be paying for health insurance, save for retirement or save for college.

None of that gives a full picture of cost of living of course, which depends on many other factors as well. But it shows that the low US tax rate is not something to day dream about, because in the end it does not give you that much in return.