Open Source


14
Mar 09

jQuery bsod plugin

So I was checking up on my twitter feed yesterday and saw a tweet that direceted me to this: http://devthought.com/wp-content/projects/mootools/BSOD/:

The script BSOD.js provides an easy-to-use class to boost the error reporting user experience of your websites.

To fully understand the characteristics of this technique please refer to this external article

I thought to myself… I can do that. I will use jQuery. So I spent most of yesterday after work learning up on how to make a jQuery extension (I wanted to be able to call it the same way as the moo-tools one)

$.bsod();

I got a bit carried away. I didn’t want just a bsod, I wanted each user to feel like the error was specifically made for them, so I added in os detection and os specific styles. I liked the way that he incorporated Spyjax (ajax for evil!), so I added that by default (you can turn it off of course if you want, it will blame a random site that is in the list). I also liked the colour changing, so that is in there too (it works only for the windows bsod though because linux and mac have images). Here are the options:

  • color: the background colour (win only, others are all black)
  • font_color: the font colour
  • error: the error message you want to display
  • os: the os (default is to guess the user’s os)
  • blame_url: boolean – true = blame a specific url
  • url_array: an array of urls you are looking to blame
  • error_array: a bunch of errors that you would like to use (one is randomly choosen)

Dependencies

Right now, the images and jQuery (tested with 1.3.1).

There is also a style that is compressed using cssTidy and inserted with the bsod.

Without further ado:

The demo (click on a word to see the bsod)

bsod.1.0.zip (with the dependencies included so you can use it right away!)

And some screen shots:

screen1 screen2 screen3 screen4

Tested in:

  • IE 8, IE 7
  • Firefox 3
  • Opera 9.63
  • Chrome 1.0.154.48

In case you missed it:

The demo (click on a word to see the bsod)

bsod.1.0.zip (with the dependencies included so you can use it right away!)


21
Feb 09

Backing things up a la Crashplan

Backing things up is very important… your hard drive will fail one of these days, and when it does you will lose everything (trust me, my laptop hard drive failed once…).

bit of HDD failure

You are backing important things up right? Oh…

Enter Crashplan. It seems like a simple way to set up your important things to be backed up elsewhere, either on another hard drive, another computer (maybe a family member’s or maybe even on their servers (don’t worry… it is encrypted quite well).

The first thing you have to do is get it (down in the right corner):

Getting Crashplan part 1

Then you have to chose the version you want to get (Linux for me obviously):

Getting Crashplan part 2

Unzip it and install it:

Welcome to The Crashplan installer

You will notice that I am installing as root, that is because of this notice:

NOTE: You are apparently not installing as root. While it is recommended to
install as root it is not required. If you continue to install as seanja
then Crashplan will only be able to back up files readable by seanja.

You can install it as a non-root (admin) user if you only want to backup files that are yours, but I have files that I would like to backup elsewhere. I just installed it using the defaults:

Crashplan Defaults

Ah… I had to install this twice because I messed it up the first time… make sure that you are in the directory that you unzipped crashplan to so that you can just run:

sudo ./install.sh

Then start Crashplan (which will auto start at the end if you told it to), and signup for an account:

Sign up for Crashplan

And if it all went well, you will now have Crashplan up and running, you can now install it on another computer using the same account, and it will recognize it as another one of your computers and let you backup to it for free.

3-backing-up


25
Jan 09

Launchy

vistastart

The keyboard has been proven to make you much faster at performing tasks. At least it has been said to be much faster, some people like your grandma may not be fast on the keyboard, but I am not sure that she really counts in the metric, she probably doesn’t use the computer to the extent that you do.

One thing that is annoying to have to do is look through the start menu for the application that you want to open to do what ever it is you want to do. That is why your desktop ends up looking like a kmenucluttered mess, you have folder shortcuts, application shorcuts, stuff you just downloaded (shame on you for not having a downloads folder set up!), and temporary files that you create for something and then forget to delete. It all adds up to create a jumble that is at least as bad if not worse than looking through the start menu for that application that you want to open. In comes the quick start bar. That group of icons beside your start menu (in Windows, KDE, and Gnome), but what is the point of that if you end up filling it to the point of your start menu? You might as well not have it at all. Fortunately the people who designed the Windows Vista start menu realised this and added in a Search box, and fancy that, so did the guys in KDE land. The only problem with those search functions is that they attempt to do too much, first they search the start menu (which takes way too long in my opinion), and then if they find nothing, they offer to search the entire computer (at least Vista does, I am assuming that KDE does too). This takes even more time.

 

launchy

Enter Launchy. Launchy is a small program that runs in the background waiting for you to press the key combination that you set up (mine is win + space) it has already scanned the contents of your start menu, and/or any other location that you specify (it doesn’t have to look at your start menu… it could just be a specific folder on your computer) and it guesses, based on what you type, what program you want to run. If it can’t find what you want, you type in gibberish, or mistype, or specifically type in something you don’t have, you can make it default to searching google for what ever it was that you typed (by enabling the weby plugin and making the default search to be google). launchy-weby Launchy will then open up your default browser and enter the search term into google and google will give you the results that you are looking for. The best part is that Launchy is free OS software that runs in Windows or Linux. So go get it now, you have nothing to lose by at least trying it out.


13
Jan 09

Netbeans Subversion > Eclipse Subversion

For many reasons I prefer Netbeans to Eclipse for a lot of my programming. Since it has added in proper php support, which is more polished than Eclipse’s php extension, it has become my default IDE at work too. Another thing that is nice is that the subversion integration is very well done. One thing that is nice is that it knows that you are actually using subversion (the existance of .svn files is a good clue Eclipse…), and it will install the subversion client for you if you don’t have it installed so that you can actually use subversion. Fancy. The Plugins link is under Tools… not say… the Help menu, a much better place for it me thinks…

netbeans-annotationsOne of my favourite features is the Show Annotations for subversion… that way you can blame people for what they have done, or atleast see what changes they have made since you last looked at the file. In Eclipse it opens up 3 windows and just doesn’t seem very intuitive to me… but when you open it up in Netbeans, it meerly adds them to the left of the text, all of the lines changed for a specific commit have the name of the author is coloured blue and the comment (there is a comment right?) is shown at the bottom of the current tab.


28
Sep 08

A look at PostgreSQL

Almost all last week at work I was working on adding Postgres to the database interfacing part of our php framework. The more I worked on it and did research to figure out why things were the way that they were and why certain things didn’t work the same way as I thought, because of my limited knowledge of databases other than MySQL and a bit of Oracle, they should, the more that I liked this database backend (side note: why doesn’t chrome have an add to dictionary option when right click on something you ‘misspelled’?). It is not that one is definitively better than the other, it is just a different way of tackling the same problems (well… in my case they are pretty much the same problems…).

For the most part, simple queries that you would write are the exact same:

SELECT * FROM my_table WHERE my_column = 'something'

This will of course return all of the things in the database where my_column = ‘something’, nice and simple.

Problems sometimes arise however when you want to do more complex things. For example if you want to delete everything from two tables where one column is the same as the other:

In MySQL, easy:

DELETE table1.*, table2.* FROM table1, table2 WHERE table1.column1 = table2.column1

In Postgres, it is easy as well, but different:

(Downloading and installing Postgres so I don’t mess this up… that would be embarrassing…)

CREATE TEMPORARY TABLE mytmptable(column1 text);
INSERT INTO mytemptable(SELECT table1.column1 FROM table1, table2 WHERE table1.column1 = table2.column1);
DELETE FROM table1 WHERE table1.column1 IN (SELECT * FROM mytemptable);
DELETE FROM table2 WHERE table2.column1 IN (SELECT * FROM mytemptable);

You could do the delete in a similar way to that in MySQL, but you probably wouldn’t because the other way is simpler. It is more dangerous though because of the possibility to delete everything in your tables while you are testing by accident if you miswrite the query.

Fortunately not everything is more complicated in Postgres, for example you can do:

DELETE FROM table1 WHERE column1 IN (SELECT column1 FROM table2 WHERE column1 LIKE 'some text' LIMIT 10 OFFSET 2)

and it will have no trouble deleting things from your tables. In MySQL you cannot do this because of the way that MySQL queries the tables when it uses LIMIT and OFFSET (apparently). What you have to do is this:

CREATE TEMPORARY TABLE mytemptable(column1 text);
INSERT INTO mytemptable(SELECT column1 FROM table2 WHERE column1 LIKE 'some text' LIMIT 10 OFFSET 2);
DELETE FROM table1 WHERE column1 IN (SELECT column1 FROM mytemptable)

This makes postgres a more attractive option to me… if only it supported

CREATE TABLE IF NOT EXISTS ...