howto

How to use your iPhone while lying down in bed.

I love my phone. But it sucks to use it while lying down, because no matter how I turn it, it tries to stay right-side-up. But I've figured out a coping mechanism. So here's how to use your iPhone while lying down in bed:

  1. Lay down on your side.
  2. Turn the iPhone on it's side, so it's actually usable.
  3. Open Safari, or any other app that can't stay right-side-up.
  4. Wait for the interface to turn all sideways and worthless.
  5. Turn it so that the iPhone is completely upside-down. Most apps, Safari included, won't know what to do… so they'll freak out and stay in landscape mode.
  6. Now the landscape mode is usable!

Command-line batch cron processing for Drupal

In which our hero carries on the time-honored tradition of posting some random snippet to his blog because he might wish to reference it later.

I occasionally need Drupal to execute its cron handler more than once. Today, I was trying to regenerate api documentation for about 18,000 files, which, understandably, is broken up into several cron runs. If I wait for the natural course of things, the documentation will take about three days to regenerate. If I run cron as fast as I can, it usually finishes in less than an hour. So here's the snippet. Paste this bad boy in your favorite shell.


while true; do /usr/bin/wget -O - -q http://example.com/cron.php; done

When you're done, hit ctrl+C to end the loop.

Note that each wget call blocks until it's finished, so you don't get a bunch of wget processes spawned. Basically it ensures that the next cron job is started as soon as possible after the previous one finishes.

neuter the backspace key, save your email messages, blog posts, and sanity.

If you're anything like me, you're prob'ly a bit tired of wiping out an entire web form by hitting backspace at the wrong time. Who decided it's a good idea to make the "delete the last character" key double as a "lose my entire blog post forever and ever" key if I happen to have something besides a text box focused?

Happy day! There's a way to disable this worthless default action (assuming you use a good browser).

Go to about:config—just type that in your address bar—and change this setting:

browser.backspace_action

  • 0 – go back previous page
  • 1 - page up
  • 2 - (does nothing)

Change it to 2 to disable this horrid default, then use the forward and back hotkeys instead...

(via)

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.