howto

a drupal path redirect bookmarklet

i threw together a fancy little javascript bookmarklet to create redirects in drupal, and figured i'd share:

<a href="javascript:d='example.com/';location.href='http://'+d+'admin/build/path_redirect/new?edit[redirect][redirect]='+encodeURIComponent(location.href.split(/[\?#]/)[0].replace(RegExp('https?://'+d,'ig'),''))+'&edit[redirect][query]='+encodeURIComponent(location.href.indexOf('?')&gt;-1?location.href.split(/[\?#]/)[1]:'')+'&edit[redirect][fragment]='+encodeURIComponent(location.href.indexOf('#')&gt;-1?location.href.split(/#/)[1]:'')+'&edit[path]='+encodeURIComponent(String(''+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text)).replace(/[^a-zA-Z0-9]+/g,'-').toLowerCase());">new path redirect</a>

for this to work you need the path redirect and prepopulate modules installed... then simply replace "example.com" in the snippet above with your domain name, and save the link as a browser bookmark.

now click on it, and it will add a redirect to the current page. if you select any text before clicking the bookmarklet, it will use that text for the redirect path. this bookmarklet supports both internal (drupal) and external paths. it also works with urls containing queries (?foo=bar) and fragments (#baz). tested in ie, firefox and safari.

have fun!

howto: remove candle wax after you get it all over your desk

so i'm a moron. i started playing with a candle that was burning on my desk and all the melted candle wax spilled and made a huge mess. i wiped up some of it, but the wax was drying and things were getting really gross... scraping and scrubbing did absolutely no good. here's what worked:

  1. cut open an old sock
  2. lay it down on the candle wax
  3. heat up an iron (i used "cotton blend")
  4. set it on the sock
  5. wait for the wax to melt
  6. lift up the sock, notice that there isn't any more wax on the desk
  7. congrats! throw away the sock

simon says

sudo make me a sandwich

one of the most annoying things about sudo is the inevitable game of "Simon Says". today i learned a coping technique. the Ubuntu wiki says:

sudo !! will repeat the last command entered, except with sudo prepended to it.

ubuntu users! repent now!

there's still hope. convert to the one true desktop environment:

sudo apt-get install kubuntu-desktop

the above command will install KDE, the one true desktop environment. it will also change your life.

snippet of the day: trim a string (the smart way) with php

i reworked the feed reading signature images i made a while back and added something to trim the strings to a decent length without breaking words. so here you go. a one-liner that'll trim a string to a decent length, and break it on whitespace:

if (strlen($blog_title) > 35) $blog_title =
array_shift(explode("|||", wordwrap($blog_title,
35, "|||"))) . "...";

howto: make your fresh Windows XP install usable

my roommate just got a new laptop for his trip to Cambodia, and we were talking about what he needed to do to make windows xp usable. a few quick downloads and he's well on his way.