February 15, 2004

Thunderbird & Imap

I’ve been trying out Thunderbird every once in a while, but I always ended up going back to Evolution because certain folders wouldn’t display.

Today I finally found the bug that explained why — turns out I just needed to lower the number of connections it tries to use on the IMAP server.

Posted by Bill Stilwell at 10:56 PM | Comments (0)

Mozilla/Fire* Speed Improvements

Two sets of mozilla pref settings that can speed up layout times and network responsiveness. (They did for me anyway. YMMV.)

Posted by Bill Stilwell at 08:21 PM | Comments (0)

February 14, 2004

So your hard drive is failing

My primary hard drive began to fail yesterday - making pinging noises, then crashes, then refusing to boot w/out appropriate religious iconography present, etc., so I decided to try and clone it to a new hard drive. That I’m using Linux (Gentoo specifically) made this easier then I expected [1]. Here’s what I did:

  1. bought and installed new hard drive
  2. partitioned new hard drive using same scheme as failing hard drive (small boot partition, swap partition, main partition) using cfdisk
  3. mounted main partition under /clone - mount /dev/hdb3 /clone
  4. copied all data to new drive using rsync - rsync -va --exclude=/proc/* --exclude=/dev/* --exclude=/boot/* --exclude=/clone/* --exclude=/tmp/* / /clone
  5. waited for rsync to finish. and waited. 90G takes a while…
  6. copied over boot partition
  7. ran grub to install MBR on new hard drive
  8. reboot w/failing hard drive disconnected
  9. get on with my life!

1 Ok, it’s probably not all that difficult for other operating systems given proper software, but it was cheap ‘n easy.

Posted by Bill Stilwell at 04:11 PM | Comments (0)

February 06, 2004

Give a Geek A Command Line

And they’ll tell you a more obscure way to do it. My perl contribution is shamefully unterseified, here it is without all those wasteful variables:

perl -MLWP::UserAgent -e 'LWP::UserAgent->new->request( HTTP::Request->new(GET=>"http://slashdot.org/"))->headers->scan( sub {print "$1: $_[1]\n" if $_[0] =~ /X-(Bender|Fry)/;});'

Posted by Bill Stilwell at 07:21 PM | Comments (1)

February 04, 2004

Java 1.5 Beta Released

J2SE 1.5 Beta - 1.5 in a Nutshell, new features.

Posted by Bill Stilwell at 11:10 PM | Comments (0)

New Moz stuff

Two upcoming releases to look forward to: Firebird 0.8 (Monday) and Mozbot 2.6 (“in a few weeks”).

Posted by Bill Stilwell at 07:23 PM | Comments (0)

Bookmarklets

Bookmarklets are a cool way to make producer/editors of your site very happy very easily. Most medium to large web sites have a web based editing system. For example, if it’s a site with articles, you might have:

http://www.example.com/article/story.tla?id=1234

and there will be a corresponding edit page for this article:

http://internal-site.example.com/edit/edit.tla?storyid=1234

If editors are browsing the public site and want to edit the article, they then have to go into the editing interface and (depending on the hostility level of the editing interface) enter the id for the article, or browse through a category system, or do a search, etc. Wouldn’t it be great if they could jump to the editing screen with the click of a button?

Enter bookmarklets. Bookmarklets are essentially chunks of javascript that are executed when you click on a browser bookmark. For example, if you create a new bookmark and enter this for the location:

javascript:alert('Hi there!');

when you click on that bookmark, you’ll get a javascript pop-up saying “Hi there!”. You can put this chunk of javascript into an anchor tag that you can then put on a webpage. People can drag this link to their Links toolbar (in IE) or personal toolbar (mozilla, etc.):

<a href=”javascript:alert(‘Hi there!’);”>Hi!</a>

becomes:

Hi!

So, you’ll probably see that it’s a simple matter of a regular expression to grab the id from the public site URL and send the user to the edit page. Let’s look at how we might do this:


  1. Grab the current page url: u=window.location.href;

  2. Grab the id variable from the url: u.match(/id=([^&]*)/); - an alternative regexp here if you know ids are always digits would be /id=(\d*)/. An important consideration is to not grab too much (e.g., if our URL query string was id=1234&section=news, the regexp /id=(.*)/ would be bad.) [Special Bonus Problem: what if your query string has something like: sid=4567&section=news&id=1234 ?]

  3. Send the user to the edit page: location.href='http://internal-site.example.com/edit/edit.tla?storyid='+RegExp.$1; (Javascript regexps put match values (i.e., the bit we captured with ([^&]*)) in the variable RegExp.$#)

That’s it! Putting it all together we get:

javascript:u=window.location.href;u.match(/id=([^&]*)/);
location.href='http://internal-site.example.com/edit/edit.tla?storyid='+RegExp.$1;

Now, let’s suppose we want to make the bookmarklets a little friendlier - what happens if the editor clicks the bookmarklet when they’re on a page without an id? They’re likely going to get an error page, which isn’t very helpful. It’s pretty easy to create an alert box if our match was unsuccessful.

First, we’ll need to save the result from our match attempt: id=u.match(/id=([^&]*)/);.

Second, we’ll check to see if id is null. If it isn’t, the user goes to the edit page, otherwise they get an alert:

if(id!=null){location.href='http://internal-site.example.com/edit/edit.tla?storyid='+RegExp.$1;}else{alert('No story id found');}

That’s it! Final result:

javascript:u=window.location.href;id=u.match(/id=([^&]*)/);
if(id!=null){location.href='http://internal-site.example.com/edit/edit.tla?storyid='+RegExp.$1;}
else{alert('No story id found');}

If your regexp needs are more complicated then presented here, try this article. You can also find many cool (and much more complex) bookmarklets here.

Posted by Bill Stilwell at 05:16 PM | Comments (0)