Spinning down external USB drives with TomatoUSB

My most recent power bill was 30% higher than usual. Yikes! So how to save some money?

If you are using TomatoUSB and have a USB hard drive connected to it, then you can save some money — and extend the life of the drive — by having it spin down when idle. For some crazy reason this doesn’t happen automatically.

Luckily, some kind individual wrote a small program that can easily be run on TomatoUSB. The instructions are pretty easy to follow, but here are the basics:

  1. Download sd-idle-2.6.
  2. Uncompress the binary and put in a safe place on your USB hard drive.
  3. Create a file called mount.autorun so the program will run automatically.

That’s it! You’ll need to either reboot your router, unmount/mount your hard drive, or manually start the program for the first time. By default it will spin your drive down after 15 minutes.

Read More

Android Notifier

A few days ago I stumbled upon the coolest app I’ve ever put on my phone: Android Notifier.

This app takes all the notifications from your phone like incoming calls, SMS/MMS messages, battery status, etc, and displays them on your desktop. Automagically. You just install the app on your phone, install the app on your desktop, and BAM! It magically sends notifications to your desktop.

It is smart enough to use the notification system appropriate for your system, like Growl or libnotify, and provides an encryption option if you are worried about other people seeing your txt messages as they are sent to your desktop.

Anyways, I’m loving it. I often forget my phone in my bedroom in the morning, which makes me miss calls because it isn’t loud enough for me to hear in my office. It also warns me when my battery is getting low.

Read More

Image optimizing WordPress plugin

I recently stumbled on the WP Smush.it plugin. It is a neat plugin that takes your images and automatically uploads them to the Smush.it web service so that your images are always nice and optimized. The problems with it are: A) it uploads all your images to a third party, which is slow and clumsy, B) it makes your images subject to the privacy policy and terms of service of Smush.it, which is often undesirable, and C) it can be slow if you have a pile of images to optimize.

So I created a derivative of WP Smush.it that runs entirely on your local server using littleutils (which I blogged about previously).

CW Image Optimizer (available from the WordPress plugin site) works just like WP Smush.it except it never uploads your images to a third party. Images are automatically and losslessly optimized using the opt-png, opt-jpg, and opt-gif programs provided by littleutils.

The downside is it requires Linux and littleutils, which most people won’t have unless they put forth the effort to install them. I plan on creating some step-by-step installation instructions for common Linux distributions in the near future, but in the meantime I have a great plugin to use on all my blogs, and because it is in the WordPress repo, I can easily push updates to all my blogs.

Anyways, if you use it, let me know what you think. I’m excited about actively developing this app to make it a great tool for everyone.

Read More

How to get your MSL number on Android

The MSL number is used on some carriers to keep you from getting to your phone’s configuration settings.

If you are using an Android and need your MSL number to access your phone’s configuration menu, you can load up a terminal emulator (piles available in the Market) and run:

getprop ril.MSL

BAM! It should spit back your 6 digit MSL number.

Alternatively you can call up your carrier and beg for it. :)

Read More

Run “git gc” on all repos in a directory

I occasionally like to run git gc on all my git repositories. I store the master copy of each repo in a directory in my Dropbox, so they are all in one place but with 45 repos it is very time consuming to do it manually one by one.

The solution is a bash script that will find all the repos in a directory and run git gc for each one.

The bash script (I saved it in /usr/bin/gitgc):

#!/usr/bin/env bash

echo "Running 'git gc' for $1"
cd "$1"
git gc --quiet

I then go to my directory of repos, and run:

find . -maxdepth 1 -name "*.git" -type d -exec gitgc "{}" ";"

This finds all directories that end in .git and calls my gitgc script for each one, passing in the directory name. If there is an error, it will be printed to the screen. The other informational messages won’t show up because of the –quiet parameter.

Modeled after a post I found here.

Read More

Poor man’s process monitor

I lost some money a few days ago because Apache crashed on my VPS that is running the Fake Mail Generator. I’m too cheap to pay for web monitoring, so I had no idea it happened until I noticed my earnings were down.

So I had a few options:

  1. Pay for a web monitoring service. Knowing that Apache crashed would have been nice, but I still might have to get up in the middle of the night to start it back up.
  2. Roll my own web monitoring service. This is something I really want to do, and perhaps host on a couple of cheap VPS servers, but it still has the problem of not magically starting Apache for me if it dies.
  3. Install daemontools. This is probably the best option, as it would let me use supervise to make sure Apache restarts if it dies for some reason. But I’m lazy and just want a quick solution.
  4. Rig something together in 2 minutes that will get the job done.

I went with option #4, and this is what I came up with:

#!/bin/sh
string=`ps ax | grep -v grep | grep httpd`

if [ -z "$string" ]
then
/usr/local/apache2/bin/apachectl start
fi

I saved that to a file called keepApacheRunning and made it writable using chmod +x keepApacheRunning.

Basically this little script will see if httpd is in the process list, and if it isn’t, it will start Apache. Pretty straight forward.

To make it run, I added this entry to crontab:

* * * * * /www/keepApacheRunning

This will run it every minute. So my max downtime is about a minute. I can live with that.

Read More