Archive

Archive for the ‘Random Hacks’ Category

Apache UserDir without a tilde

April 24th, 2007
Comments Off

I posted this a while back on an internal blog at my workplace, and a friend recently asked if I knew of a way for this to be done, so I’ll re-post it here. I work for a wholesale ISP, and we often take an existing ISP’s customer base, including email and personal web space hosting, and migrate it to our servers. We’ve used this hack once or twice for some migrated accounts from an ISP, who in the past, allowed users to have personal web space at their domain, but under a “normal” subdirectory of the domain, such as http://example.com/username/. Migrating their subscribers to our servers would have required a change to the Apache-style http://example.com/~username/ format, which would break existing hard links and search engine results.

Our workaround uses Apache’s rewrite module (not surprisingly, named ‘mod_rewrite’).

In the VirtualHost section for the domain I wish to affect, I add the following directives:


UserDir /home/example.com/*/WWW
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond /home/example.com/$1/WWW$2 -f [OR]
RewriteCond /home/example.com/$1/WWW$2 -d
RewriteRule ^/([^/]+)(.*) /home/example.com/$1/WWW$2
</IfModule>

Of course, change the directories to match your local setup.

Now for how it works… Say a web user surfs to http://www.example.com/username/ – The rewrite rule will first check for a file or directory at /home/example.com/username/WWW/’s existence, and if it indeed exists, Apache serves the requested file out of the referenced directory.

A couple of things to be cautious of:

  • This MAY interfere with folder’s in your domain’s website structure! User directories (based on the username) take precedence over your website directories. If a user with the username “images” happens to be added to your system, I can only imagine very bad things may happen to your visitors.
  • I don’t know how much of a strain this is on Apache. From my experience, mod_rewrite is NOT horribly efficient. If at all possible, DON’T DO THIS – just make your users deal with a standard UserDir setup. If they are horribly concerned about the “ugly” tilde in their URL, I’d suggest one of the many options out there for URL forwarding or regular domain hosting.

Random Hacks, Systems Admin

PHSI PW1R water cooler LCD hack

October 21st, 2006
Comments Off

Our workplace recently got some fancy-pants water filtration system (the PHSI PW1R) that takes tap water and filters it, ozonates it, then cools or heats it. It’s actually pretty neat, makes for some nice fresh and ice cold water (or hot water for tea, if that’s your bag). The unit itself is pretty simple. Press a button for cold water, press two simultaneously for hot. It also has a few other buttons – one to cycle through the messages on the LCD display, another to run a system test, and some unlabeled button behind a graphic that doesn’t appear to do anything. The LCD is a standard character LCD with a nice blue backlight (ah, geeks and their blue blinkenlights).

By default, the LCD cycles through some readouts showing unit consumption in gallons, some jazz about “ATS – Auto Tank Sanitation (TM)”, and “PURE WATER!” (exclamation mark included). Of course, I want to change these to our own messages now. :)

The unit has no serial ports that I could find (and I don’t think the boss would appreciate me disassembling the new water cooler to find one deep inside). After tinkering with powering up the system while holding different button combinations (and discharging several spurts of liquid in the process!), it turns out that holding down the “Display”, “Test”, and top of the two “Hot” buttons yields a management interface. From here you can change a few items, including ozone injection settings — and of course, the display!

You can scroll through the menus (and options) with the two “Hot” buttons. Items can be toggled on and off with the “Test” button, and selections can be made with “Display”. Let’s just say that it takes an eternity to set messages of any length, and you must pad messages by hand in order to center them. Now I really wish this thing had a serial port. Oh well…

Happy hacking!

Random Hacks ,

Keepin’ tabs on the neighbors

November 14th, 2004
Comments Off

For some reason I’ve taken interest in radio again. I used to be really interested in all sorts of stuff of this sort, including tuning into shortwave frequencies and learning about propagation when I was a kid.

Went out and bought myself a scanner from Radio Shack today… and of course, now I’m being nosy and listening to the local police bust my neighbors’ for beating each other with kitchen utensils or something.

So, what better to do in this case than create a website with local emergency services radio info? I present to you, http://www.joco-scanning.info/ – Police, Fire, and EMS radio information for Josephine County and Grants Pass, OR.

I’m seriously considering an MP3 stream of this…

Edit: As of 11/30, I now have a 24×7 live feed of the Grants Pass PD linked from the page.

Random Hacks ,