I really like the idea of being able to make nice small urls from really big ones like you can with snipurl.com but of course their keyword namespace is all used up. So I wrote my own. The intention is that you put it as the 404 error document for your server and when someone goes to yourdomain.com/keyword this picks that up and sees if it's in its map and if it is redirects you. You add urls using a cgi prameter which is very easy to do with Mozilla keywords. The database is a regular old ini file which php is o.k. about parsing. Since you probably don't want everyone filling up your namespace with their keywords, adding keywords is either protected by an IP address white list, or failing that a simple user name/password setup. It's all very basic, but it works and I'm happy with it at this point so I'm putting it up here. At a future date I might put in some kind of keyword management so you can see all your keywords and perhaps trim them down, but right now it's easy enough to just edit the config/db file by hand.
While writing this the biggest frustration was dealing with the config file. I tried to use the pear config module it was uber frustrating. It just wasn't easy to have an object I can load, get settings from, add settings and save. So I gave up, used the built in parse_ini_file which was super simple and is built in. Since my [urls] section is at the end I can add urls just by appending to the file.
So here it is: your very own url shortening code.
I guess I should have used snippy urls for the links in this post eh?
Update: 2006-12-25: I just changed the code that displays the snippy url to have it be in a text input, pre focussed and pre selected so you can just control-C when the page loads and it's in your clipboard. The form's action is the snippy url (via post) so you can hit enter to test your new snippy url.
Update: 2008-08-10: I made it so you can use the same mozilla keyword to add a url as you can to choose a url. I use the keyword 'w' so I can type "w cnn http://cnn.com/" in mozilla to create a snippy url. Then I can type "w cnn" to access that url. 'w' is a mozilla keyword to 'http://example.com?kw=%s'
Sunday, August 20, 2006
Sunday, August 13, 2006
duweb
duweb is a web interface to the output of the du command. It's a nice way to work out which directories are using the most disk space and allows you to mine down and find more about the subdirectories. It saves you running du -s * | sort -n and then cd and then repeating which is what I used to do.It uses WebFxLoadTree but I needed some of the functionality of the beta version 2. It's a really nice way to display trees and not have to have all the tree data when you do it.
You can run it as a cgi program where it'll load the du data out of a file in /tmp but you can also just run it as a standalone program and it fires up it's own built in webserver (thank you python libraries!)
Hope you find it useful. It requires python 2.4 since it uses the new subprocess library. Here's a link to where I found python 2.4 for osx.
Download the source for duweb.
Subscribe to:
Posts (Atom)