Shizzle

My little notebook

Changes to submitting measurements to Edd

August 29, 2009

I have made some changes to how submitting measurements works in my spoke length calculator, Edd. Up until now submission was anonymous, which had the obvious drawbacks of verification and me being unable to ask for clarification if a submission was unclear.

From now on you will have to supply an email address if you want to submit measurements for a hub or rim, but please be assured that this data will be for my eyes only. I won’t spam you or won’t give your email address to anyone.

1 Comment

In praise of Netbeans (and how I learned to hate Eclipse)

August 10, 2009

The dark ages

I use a MacBook for my development and until recently I have done my Java development in Eclipse. It is a very popular IDE and apparently very flexible and can be made to do absolutely everything. Also, all the Google Java products plugins only worked for Eclipse and that was the main reason for me to not switch.

However, it shortcomings became more and more apparent during the time I wrote my dissertation and became more serious about Java development. I noticed the following things about the OS X variant of Eclipse.

  1. It. Is. Slow. It is painful to work with an IDE that locks up every 5 minutes and whenever you open a menu that has so far not been opened. I heard something about the Java-Carbon bindings not being very good and I think performance is better on Windows but this was a real issue for me.
  2. Usability is abysmal. There are millions of message areas that pop up all the time, buttons are tiny and appear and disappear seemingly randomly. I know software development is supposed to be difficult but this is just unbearably hostile to the user.
  3. It is very much a Windows app. It feels a lot like they wrote the app to fit with the windows UI guidelines, realised that there is Mac developers too and just copied the UI button by button. I know us Mac people are demanding when it comes to OS integration but Eclipse is simply not cutting it.

The conversion

One day I was frustrated enough by how rubbish Eclipse was, that I was ready to switch IDE mid-project. I kept saying to myself that I would give Netbeans a spin at the next project but my patience with Eclipse was wearing thin. I have not looked back.

The main issue I was worried about was the project conversion process and I have to tell you it was the most seamless thing I have ever experienced. Absolutely no errors or incompatibilities turned up. I was impressed. It also turned out that Netbeans is much better at managing your classpath automatically, so conversion even resolved a few issues. The only thing I had to redo was the tomcat configuration but that took about 30 mins.

I didn’t know Java development could be bearable on a Mac

After trying Netbeans out for a few days I have the following things about it.

  1. It has a nicer UI. I know this will not get me any cred with the emacs crowd but if an application doesn’t shout “I’M UGLY!” all day long I like using it better than one that does. Call me superficial.
    I also managed to install a dark editor skin which makes Netbeans resemble Textmate a bit more which has also earned some plus points with me.
  2. Usability is way better. Buttons are clear and there are fewer of them. Netbeans also gives you more sane default behaviour so you don’t have to poke around in the settings too often.
  3. Classpath and lib folder management works. When you put something in the lib folder, it will be put on the classpath and copied into WEB-INF/lib. I couldn’t get Eclipse to do that no matter how hard I tried. I had to enable this for every JAR I downloaded.
  4. It’s faster. Not Textmate-fast but fast enough to not annoy me constantly. I like.
  5. Mercurial works out of the box. I didn’t install a plugin, I never activated anything. Netbeans just knew I was using it and started marking files as edited. (I guess this works for other SCMs too.)
Netbeans screenshot with Textmate style dark theme

Netbeans screenshot with Textmate-style dark theme

In retrospect, switching to Netbeans has been a huge boost in terms of productivity for me. I’m wondering why I didn’t try it earlier.

7 Comments

How to set OpenDNS as the DNS provider for your Speedtouch router

July 18, 2009

Here is a really neat trick on how to speed up your home internet quickly and for free.

A little background

Basically every time a browser requests a page from an human-readable address like google.com, it first needs to find out the IP address for the server. This lookup takes some time and is provided by DNS servers. However, most ISP’s DNS servers are slow because no one asks “How fast is the DNS lookup?” when they shop around for broadband.

OpenDNS

OpenDNS is a free service that does faster DNS lookup than your broadband provider. They finance themselves by showing you a suggestions page when you mistype an address and this suggestions page has some ads on it. For me that isn’t obstructive at all.

How to do it

The Speedtouch routers don’t have a GUI for changing the DNS servers so you need to login via the command line program telnet into the router, which by default has the address 192.168.1.254 . If you have changed the IP address of your router you will need to use that instead.

telnet 192.168.1.254

The default user for Speedtouch routers is Administrator and the default password is just blank. Obviously if you changed these setting then you’ll have to enter those details.

Now you need to issue three commands which change the DNS settings. First delete the old DNS settings:

dns server route flush

Then add the two OpenDNS ones:

dns server route add dns=208.67.222.222 metric=1 intf=RoutedEthoA
dns server route add dns=208.67.220.220 metric=1 intf=RoutedEthoA

Now save everything with

saveall

That’s it. Try it out now by mistyping an address, if you can see the OpenDNS page then you’ve done it!

No Comments

A fast and free Safari “plugin” for delicious.com

May 2, 2009

Having changed over from Firefox to Safari recently, I sorely missed a free and fast delicious.com plugin. Then I spotted a new feature of WebKit, Safari’s open-source underpinnings: HTML5 offline database storage. This allows Safari to have a local copy of all your public delicious bookmarks, which are superfast to search too.

If you want to try it out visit http://lenni.info/tools/overdrive/.

Well, the title is a little misleading. It isn’t really a plugin; it is a little web app that makes use of advanced browser features. Initially, this site will only download the last 100 bookmarks but over time all of your bookmarks will be downloaded – just leave the window open for a few minutes. To search your bookmarks, just enter your search term into the search box at the top.

I have placed an intentional restriction on the application. You can’t download your private bookmarks since that would mean you’d have to enter your Yahoo password into the site, which should make you nervous.

If you notice any quirks, send me an email or post a comment here.

06/07/2009:
I have made two updates to the app: Firstly, you can now search for two or more search terms, ie “banking online” will now search for bookmarks that match “online” and “banking”. Secondly, the annoying behaviour of the bookmarks appearing at the bottom of the list during the download is gone too. Use Shift+Reload in order to clear your cache and to get the newest version of the app.

I also fixed a little bug where sometimes a wrong tag list was being downloaded. If you have the feeling that some of your bookmarks are missing, please reset the app.

14 Comments

How to “inject” the current mercurial revision into your JS load requests

March 29, 2009

When you do web development you will soon have to find a way to force users to download a new version of your JavaScript files before their browser cache actually requires it. The best way to do this is just add a made-up GET argument to the file name when you load the script and change this when you upload an new version of the script.
It should look something like this:

<script src="behaviour.js?revision=14" type="text/javascript"></script>

One of my JavaScript “build scripts” has this one automated and reads the current revision from my mercurial repository of this project. In order to just get the revision number type this in the console when you are cd’ed into the project folder (I recognised that this is not the most elegant of bash scripting, but it will do the job):

hg log -l1|grep changeset|grep -o  "\([0-9]\+\):"|grep -o "\([0-9]\+\)"

In your HTML files you will need a little placeholder that will mark all those places where the current revision number should be injected. I chose the string {REV}. Your HTML header should look like this:

<script src="behaviour.js?revision={REV}" type="text/javascript"></script>

Now, the next step replaces all occurrences of the string {REV} with the number of the current mercurial revision. The following script takes one argument: the filename (or file pattern) that should be scanned for the string {REV}.

#!/bin/bash
export rev=`hg log -l1|grep changeset|grep -o  "\([0-9]\+\):"|grep -o "\([0-9]\+\)"`
echo "Replacing all occurences of {REV} in $1 with the current hg revision "$rev
perl -pi -e 's/{REV}/'$rev'/g' $1

So put this code in a file, say, replace.sh, make it executable and then run it with something like

./replace.sh index.html

No Comments

Let Google host jQuery for you

March 15, 2009

If you want to make use of Google’s hosting platform for all sorts of JavaScript libraries and want to use jQuery in your site, just insert this snippet into the header of your HTML document.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

This blog post explains why Google hosting is a Good Idea.

Addition

We have started using Prototype and script.aculo.us at work. Here’s Google’s URL for it:

<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js" type="text/javascript"><!--mce:1--></script>
<script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.2/scriptaculous.js" type="text/javascript"><!--mce:2--></script>

1 Comment

TinyURL bookmarklet

February 28, 2009

Do you love TinyURL but wished that there was an easier way of creating your shortened URLs? Here it is: I have written a little bookmarklet which is heavily influenced by the delicious one.

Just drag the following link to your bookmarks bar:

TinyURL!

Let me know how it is working in the comments.

No Comments

How to install Mozilla Bespin

February 19, 2009

Mozilla Bespin a cool new project that lets you edit your code online Google Docs-style. The project has so much potential and I’m really excited what’s going to happen with this.

If you want to take Bespin for a little spin you can either check out the online demo or install the whole thing on your own machine. Here is how. These instructions have been tested on OS X. I can’t see a reason why it wouldn’t work with other *nix platforms and maybe even on Windows. Let me know in the comments how it is working.

Firstly, you will need to grab the source. If you have mercurial installed then just do a 

hg clone http://hg.mozilla.org/labs/bespin/

Otherwise just download the tarball and extract it somewhere in you home directory.

Once your have everything on your hard disk open a terminal and go into the Bespin directory. Then change into the backend folder

cd backend/python

and install all the requirements with 

python bootstrap.py 

This will take a few moments. After it is finished configure your installation and start the local server with the following three commands:

source bin/activate
paver create_db
paver start

If  you see something like Server starting on localhost:8080 in the terminal it means everything went well and you are good to go. Just point your browser to http://localhost:8080 and off you go.

6 Comments

Communication & Networks coursework made easier

January 26, 2009

I have written a little script that converts the raw text file from the course website and gives you a file with comma separated values. CSV files can be opened by any old spreadsheet program. It has the added bonus of converting the RTT from scientific notation to normal decimal numbers.

The script is written in Python so you need to have that installed; OS X and Linux will have it out of the box. If you have Windows and don’t want to install Python you can use the lab computers at UCL.

The script is here.

Download the .py file in the same directory as the coursework .txt and then run

python txt2csv.py <yourinputfile.txt>

This should create a file called coursework.csv. If you find a bug please stick it in the comments.

No Comments

How to deactivate one macport variant and switch to another one

January 25, 2009

Lets say for instance you have installed PHP with MySQL support with macports:

sudo port install php5 +mysql5

But later on you decide you want to use SQLite, too, you’ll have to rebuild PHP with SQLite extensions, like this.

sudo port install php5 +mysql5 +sqlite

Now you have to deactivate the MySQL-only build and activate the one with SQLite bindings. I couldn’t find it anywhere in in the macports manual so here it goes.

Get a list of your current PHP5 builds with

$ sudo port activate php5
Password:
---> The following versions of php5 are currently installed:
---> php5 @5.2.8_1+apache2+macosx
---> php5 @5.2.8_1+apache2+macosx+mysql5 (active)
---> php5 @5.2.8_1+apache2+macosx+mysql5+sqlite
Error: port activate failed: Registry error: Please specify the full version as recorded in the port registry.

Then copy and paste the currently activated port and use the deactivate command.

sudo port deactivate php5 @5.2.8_1+apache2+macosx+mysql5
---> Deactivating php5 @5.2.8_1+apache2+macosx+mysql5

Then copy and paste the one you would like to use and use the activate command:

sudo port activate php5 @5.2.8_1+apache2+macosx+mysql5+sqlite
---> Activating php5 @5.2.8_1+apache2+macosx+mysql5+sqlite

That’s it.

1 Comment

Switch to our mobile site