Archive for the ‘Hacks’ Category

No more hotlinking images

For those who use Apache 2.x, this is a nice trick to keep people from hotlinking your images. I’ve seen a few variants of it, but this one I picked up most recently from a slashdot comment, of all places.

Make sure you have enabled mod_rewrite, then add this in your .htaccess file for any directory with images in it:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain\.com [NC]
RewriteRule .* /files/goatse.jpg [NC,L]

to redirect to an awful image, or use my own personal variant:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]

which doesn’t return *anything* if someone else hotlinks your images. If they like your images enough, they can like them enough to save a copy on their own webserver.

WRT54G Multiple External IP Trick

To assign multiple external IP addresses to a WRT54G/S, you have to push a multiline variable into the rc_firewal nvram variable (non-volatile ram):


nvram set rc_firewal="
iptables -t nat -I PREROUTING -d x.y.z.1 -j DNAT --to-destination 192.168.1.x
iptables -t nat -I PREROUTING -d x.y.z.2 -j DNAT --to-destination 192.168.1.x
"
nvram commit

This will protect the changes against being lost when the router is reset.

Ubuntu Dapper studio patched kernel 2.6.17

I have compiled an initial 2.6.17 kernel for Ubuntu Dapper Drake, as described on ubuntustudio.com. It has the EVMS patch needed by Ubuntu as well as the realtime patch installed. This version is not usplash patched. Files : kernel-headers-2.6.17-rt7_1_i386.deb, kernel-image-2.6.17-rt7_1_i386.deb

WordPress 2.0.3 upgrade

I have created a wordpress “diff” which can be applied to easily upgrade WordPress 2.0.1 to WordPress 2.0.3 instead of going through the long and involved method on the WordPress Codex. Use diff and a grain of salt with wordpress-patch-2.0.1-to-2.0.3.gz.

Ubuntu touchpad annoyance

After more than six months of dealing with the Synaptics touchpad driver interpreting my hand brushing against the pad as a “click”, I found a small change to xorg.conf which will take away the sting of using a touchpad with Ubuntu/Kubuntu.

Simply add the following lines in /etc/X11/xorg.conf in the InputDevice clause for the touchpad, and restart X:

Option "SHMConfig" "on"
Option "MaxTapTime" "0"

Just had to share that, it took me so long to get up the resolve to actually *look* for a solution …

Creating TTS Prompts for Asterisk with Realspeak

I was playing around with using ScanSoft Realspeak for Linux, and finally found the “magic sequence” to generate the appropriate GSM prompts for Asterisk.

    Requires:

  • Standard installation of Scansoft Realspeak 4 with American English Jill voice
  • Debian’s libgsm-tools and sox


cd /usr/local/ScanSoft/RealSpeak_4.0
echo " - TTS being performed on $1 ... "
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ScanSoft/RealSpeak_4.0/api/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ScanSoft/RealSpeak_4.0/speech/components/common/
./standard "American English" Jill ./speech text.txt
echo " - Converting to 8000Hz WAV ... "
sox -r 8000 -t raw -w -s /usr/local/ScanSoft/RealSpeak_4.0/standard.pcm text.wav
sox text.wav text.au
cat text.au | toast -c -s > text.gsm