Htaccess trick

Here's what I ended up putting in an .htaccess file for each of the various sites I run/own/manage to participate in the SOPA/PIPA protest today:

RewriteEngine On
RewriteCond %{TIME_HOUR}%{TIME_MIN} >0459
RewriteCond %{TIME_HOUR}%{TIME_MIN} <1701 RewriteCond %{TIME_YEAR}%{TIME_MON}%{TIME_DAY} =20120118 RewriteRule ^(.*)$ http://sopastrike.com/strike/ [R=307,NC,L]

Learn something new every day. *g*

This forwarded each site to the protest page for a certain time frame (the length of the protest, adjusted for the server's time). You could use something like that to put a site in maintenance mode, for example. Just be sure to add a RewriteCond that checks for your IP so you can get to the site to test it. ;)

This is just to say

I haven't checked
your Facebook status
or followed
your Twitter

on which
you were probably
announcing
big things

rather than
telling your friends
directly
in person
via email
or on the phone

Forgive me
I haven't
the time or
the attention span
to sort the dreck
from the
important stuff

—Annie Mullin
2011

(With apologies to William Carlos Williams *g*, whose original is one of my absolute favorite poems.)

Action alert for Americans

If you haven't done so already, please be sure to contact your representatives and senators today and tell them to vote against SOPA/PIPA.

More information:

EFF: Stop the Internet Blacklist Legislation

Stop American Censorship

PROTECT IP / SOPA Breaks The Internet

Don't Censor the Net!

Django, MySQL, and Windows 7 64-bit installation tips

Here are the solutions to a few annoying things that caused issues when I was installing Python, Django, and MySQL on a new Windows 7 64-bit laptop.

1. Be sure to set your PYTHONPATH variable.

After I installed ActiveState Python, it didn't set up the environmental variable. I added it and restarted the command window, and voilà. (I don't remember having to set that up manually on my XP machine, but I could be mistaken since it's been a very long time since I installed everything on that machine. Regardless, it's a good thing to check. *g* Also check your PATH variable, to make sure that Python, Django, and MySQL are all in there.)

2. Assign the read_default_file setting in the database dictionary.

I was getting "Error 2003: Can't connect to MySQL server on 'localhost' (10061)." It wasn't the firewall blocking the port, because mysql is running on a socket. (Though I could be wrong, as I just switched over to Codomo from ZoneAlarm, which had issues with Win7 64-bit and Filezilla, and I haven't learned all of Codomo's quirks yet, so who knows?) Even though I've got the admin service set up to execute "C:\progs\mysql\bin\mysqld" --defaults-file="C:\progs\mysql\my.ini" MySQL, it still wasn't finding the ini file for some reason. Weirdly, telling Django which my.ini file to run MySQL with fixed it. In your settings.py, in the database section, you'll add the OPTIONS entry:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'database_name',                      
        'USER': 'username',
        'PASSWORD': 'password',
        'HOST': '',
        'PORT': '',
        'OPTIONS': {
            'read_default_file': 'c:\path\to\your\my.ini',
        },
    }
}

Convert flac to mp3 using ffmpeg, retain ID3 tags

Finally found the info I needed in the ffmpeg docs to keep the ID3 tags when converting from flac to mp3:

for FILE in *.flac;
do
    ffmpeg -i "$FILE" -ab 320k -map_metadata 0 "${FILE%.*}.mp3";
done

ETA 8/27/2012: updated "-map_meta_data 0:0" command to "-map_metadata 0" for the new version of ffmpeg.