Shizzle

My little notebook

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

3 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

Installing miranda on Mac OS X

January 22, 2009

EDIT: It seems that miranda is again distributed as a .tgz archive, therefore revert back to the original instructions here.

This is little walk-through for installing the Miranda programming language on OS X. There are the original instructions here, but they things have changed a little since that document was written. Hence this little write-up.

Firstly, download the OS X tarball from the Miranda downloads page or the direct download link.

Open your OS X Terminal (search for it in Spotlight) and go to the directory the tarball was downloaded to.

Then type 

sudo tar xpf mira-2032-MacOSX.tar -C /

This installs bunch of files in your /usr directory, hence the required su access. That’s it. Just run

mira 

and off you go. If you know about a nice IDE or editor with syntax highlighting please post it in the comments.

No Comments

Setting up Django at Railsplayground

October 19, 2008

I have been using Railsplayground for a while to host my Django apps. I am really happy with them and their prices are pretty much unbeatable.

I had set up a Django app a while ago and everything went groovy, therefore I didn’t take any notes. Yesterday I tried to host a second project in a new project folder. As last time I followed the instructions from the  Railsplayground wiki.

Apart from one thing. I didn’t create my project on the server with django-admin.py but instead just copied the project folder from my Macbook. I was fiddling with the dispatch.fcgi for hours before I tried to create a project with django-admin.py and then copied all files from my Macbook into it. Voila! It works!

So don’t make the same mistake and think that you can skip that step. The Django project folder needs to be created on the server. Can anyone enlighten me why that is? I overwrote everything in that folder with my local copy so there shouldn’t be any difference, should there?

1 Comment

[Fixed] Eclipse editor text bouncing up and down under OS X

October 15, 2008


Eclipse squashing lines

Originally uploaded by Lenniboy

I used to have terrible problems with Eclipse on my MacBook running OS X. Editor text was bouncing up and down and all my lines were squashing. Have a look at the photo if you think I’m crazy.

Finally I have managed to find out what has caused this behaviour: It is the font size, which was set to 9.5. I’m not sure if the small size or the .5 bit that is to blame but but as soon as I set it to 11pt everything was fine.

I’m happy I found this because I was very short of changing over to XCode.

No Comments