2Ze.us Updates

There has been quite a bit of recent activity in my 2ze.us project since I first released it nearly a year ago. My intent was not to become a competitor with bit.ly, is.gd, or anyone else in the URL-shortening arena. I created the site as a way for me to learn more about Google's AppEngine. It didn't take very long to get it up and running, and it seemed to work fairly well.

AppEngine and Extensions

I was able to basically leave the site alone on AppEngine for several months--through about September 2009. In that time, I came up with a Firefox extension to make its use more convenient.

The extension allows you to quickly get a shortened URL for the page you're currently looking at, and a couple of context menu items let you get a short URL for things like specific images on a page. Also included in the extension is a preview for 2ze.us links. The preview can tell you the title and domain of the link's target. It can tell you how much smaller the 2ze.us URL is compared to the full URL. Finally, it displays how many times that particular 2ze.us link has been clicked.

That as all fine and dandy. It was the second Firefox extension I had ever written, and it's still running strong. In June or July of 2009, I started working on a little program to make it easier for me to interact with Twitter the way I wanted to. This was a great opportunity for me to incorporate 2ze.us into the application so any URL I wanted to post to Twitter would automatically be shortened for me, using my own shortener.

Porting to WebFaction And PHP

Anyway, around the end of September 2009, I noticed that there were a lot of problems with 2ze.us. It was slow and sometimes completely unresponsive. Certain URLs would redirect to their full URLs, while others wouldn't. The Firefox extension stopped working nicely. Oh yeah, and AppEngine rolled back to a previous revision of the code without me telling it to. That's when everything just died. It didn't take long for me to decide to migrate my project from AppEngine onto my awesome WebFaction hosting.

At this point, I was faced with a small dilemma: keep the code in Python, or port it to PHP. I opted to port it over to PHP, because I didn't want all of the overhead of a full Django instance for a site that needed to be very zippy. And I was unacquainted with other Python options.

By early October 2009, I had managed to turn the project into a PHP beast, running on Apache. It was a lot more responsive than AppEngine ever let 2ze.us be. There were a few bumps along the road, what with the extension and Twitter client relying on various parts of the site. Eventually it got to a point where I could just let it sit and work.

Chromium Extension

Sometime around the end of December, I decided to write another extension for 2ze.us, only for Google Chrome and Chromium this time. This extension isn't quite as feature-packed as its Firefox brother, but it gets the job done.

Clip2Zeus

Shortly after "completing" the Chromium extension, I had what seemed like a pretty original idea. Who knows if it really is, but I still haven't seen another tool quite like the one that I made as a result of this idea. I thought, "Now, why should I need to install an extension in each Web browser I use on each computer I use? Is there a better way?"

The answer came quickly: a standalone, desktop application. Write one program that handles shortening URLs for you. My laziness told me to make a program that monitors your system clipboard for URLs. If a URL is detected, try to shorten it, and update the clipboard contents in place. Boom. Done. All extensions become useless beyond things like the URL preview (which is very useful, imo).

The next question I asked was, "Do I make it platform-dependent? Should I stick it to the majority of computer users and write my tool for Linux only? For OSX only? For, uh... Windows only?" Again, an easy question to answer. Support them all or don't even bother writing the application.

A week's worth of midnight hacking saw the birth of Clip2Zeus 1.0a. It's a cross-platform compatible desktop application that does exactly what I just mentioned. When it's running and detects a URL on your system clipboard, it will try to shorten it and update it in your clipboard. If you copy a block of text, the application will only modify the URLs in that block of text--meaning the block of text will still be in your clipboard, but it will have shorter URLs.

I use the program every day at work (on OSX). It's been very fun for me to see a short URL any time I copy a nasty URL to my clipboard. Imagine that; I'm a big fan of my own work...

Tornado

Lately, I've noticed that the site was getting kind of slow again. Sometimes it would take several seconds for Clip2Zeus to shorten URLs in my clipboard, when it was normally instantaneous. Every once in a while, Clip2Zeus would completely fail to connect to the website.

One of my friends has asked me a lot of questions about the Tornado framework in the past months. I had read a few things about Tornado when it was open-sourced last year, but I didn't really feel the need to dabble with it. These questions prompted me to tinker a little.

Last night I re-ported 2ze.us to Python, using the Tornado framework this time. So far I'm very impressed with its responsiveness. The framework offers a lot of neat little utilities, and it is very fast (as reported by dozens of other reputable sources).

On top of the speed increase that came with the transition to Tornado, my RAM usage on WebFaction has come down by nearly 100MB. Just by turning off the one Apache-backed website. Now I'm nowhere near my RAM cap! Wahoo!!

Enough rambling. Like I said at the beginning of this article, a lot has been happening with this project in the past year. I didn't even think about all of the time I put into projects related to my simple little side project. Looking back, I'm quite satisfied with how things have unfolded.

Statistics

Here are some simple statistics for 2ze.us. Since March 2009...

  • 5,252 URLs have been shortened using 2ze.us
  • 2ze.us links have been clicked 198,267 times
  • 315,951 URL characters have been turned into 11,532 characters

In April 2009...

  • 217 URLs were shortened
  • 2ze.us links were clicked 617 times

In February 2010...

  • 1,182 URLs were shortened
  • 2ze.us links were clicked 32,830 times

Not too shabby for a side project.

GIT-SVN on Slackware 12.2

With all of the hype that git has been receiving lately, I started playing with it a while back to see if it suited me and my wants/needs. I found it to be an interesting utility. I won't go into any details simply because I'm not really all that knowledgeable about all the ins and outs of version control systems, but I will say that I have decided I like it. I'm still not sure whether I prefer GIT over SVN or SVN over GIT.

My problem is that basically all of my projects are based on SVN repositories. I don't want to have to start up a new GIT repository for each of my past projects. Fortunately, there is an interface for GIT to use SVN repositories called git-svn. I use this utility primarily on my EeePC because it saves a good amount of space on my small disk (the git-svn versions of the working copies are typically about half the size of their svn counterparts). Sometimes it's a little wacky, but it works well enough for my needs.

I started using this git-svn utility on a Debian-based distribution. That meant it was insanely simple to get up and running: sudo apt-get install git-svn. I recently installed Slackware 12.2, and I was surprised to find out that the git-svn utility wasn't immediately available to me.

I did some googling to see if others had encountered the same problem. There were several accurate hits, but I couldn't quite find the solution I needed. In the end, I finally got things working. The following information describes what I did to achieve this monumental success.

Trying git svn

The first roadblock that I encountered, obviously, was finding out that git-svn didn't work on my shiny new Slackware installation. After doing a bit of research, I learned that I could substitute the familiar git-svn command with git svn and continue using it as I previously had.

Installing Dependencies

Once I learned about git svn and tried it out, I got a nasty error about Alien/SVN. I've lost track of the original error, and for that I apologize. Doing a little bit of research led me to execute this command as root:

cpan Alien::SVN

I'm not sure exactly whether that step is required, but you might as well do it :).

Next, I downloaded a couple SlackBuilds to create my own Slackware packages suited for my computer.

For each SlackBuild, you must download the original source code along with the actual SlackBuild itself. For example, when retrieving the necessary files for swig, I must download both swig-1.3.35.tar.gz and swig.tar.gz from the link specified. Here are some example commands, which should be run as root:

mkdir -p ~/downloads/slackbuilds; cd ~/downloads/slackbuilds
wget http://slackbuilds.org/slackbuilds/12.2/development/swig.tar.gz
tar zxf swig.tar.gz
cd swig/
wget http://downloads.sourceforge.net/swig/swig-1.3.35.tar.gz
./swig.SlackBuild
installpkg /tmp/swig-1.3.35-i486-1_SBo.tgz

The commands above should create a new directory in /root/ called downloads/slackbuilds. Next, the SlackBuild for swig will be downloaded and extracted, after which the swig source code will be downloaded. The SlackBuild is executed, rendering an installable Slackware package. Finally, the package is installed onto the system.

The process is basically the same for the subversion-bindings SlackBuild. On my system, however, I had to modify the stock SlackBuild slightly. I didn't install Apache on my EeePC because I don't use it and it would just be taking up space. When I tried to execute the SlackBuild for subversion-bindings straight from the archive, it complained about a missing apxs file, which has something to do with Apache.

To avoid the error, I modified the subversion-bindings.SlackBuild script to ignore the apxs thingy. The original ./configure section looked like this:

CFLAGS="$SLKCFLAGS" \
./configure \
  --prefix=/usr \
  --mandir=/usr/man \
  --enable-shared \
  --disable-static \
  --with-apr=/usr \
  --with-apr-util=/usr \
  --with-apxs=/usr/sbin/apxs \
  --with-neon=/usr \
  --with-zlib=/usr \
  --with-pic \
  --with-ssl \
  --build=$ARCH-slackware-linux

I just removed the line that says --with-apxs=/usr/sbin/apxs \ and ran the SlackBuild script again. Worked like a charm.

At this point everything appeared to be able to work properly. Running git svn from the command line no longer spit out that nasty error I mentioned earlier. Instead it gave me the options I would expect to see.

That's when I tried to update an existing working copy of an SVN repository. It gave me this error:

$ git svn rebase
Authentication realm: <http://special.domain.com:80> Subversion - code
Password for 'myuser': Can't locate Term/ReadKey.pm in @INC (@INC contains:
/usr/lib/perl5/site_perl/5.10.0/i486-linux-thread-multi /usr/lib/perl5
/site_perl/5.10.0 /usr/lib/perl5/5.10.0/i486-linux-thread-multi /usr/lib
/perl5/5.10.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.10.0
/i486-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5
/vendor_perl .) at /usr/libexec/git-core/git-svn line 3071.

That's not very nice, now is it? The solution was fairly simple: install Perl's Term::ReadKey module. As root, execute the following command:

cpan Term::ReadKey

After doing that I was able to happily update my working copy and move on.

I don't envision that this article will be the all-knowing, all-powerful resource for how to use git-svn on Slackware, but I sure hope it will help some other folks who run into the same problems as me.

Setup a favicon.ico in Django

Up until a couple weeks ago, I had never installed a FavIcon on any of my Django sites. I never really thought about it until one day I enabled the SEND_BROKEN_LINK_EMAILS setting for one of my sites. As soon as I did that, I was able to track down links to broken pages very quickly. It also notified me that I didn't have a favicon.ico file setup anywhere on my site, and there are a great many programs out there that look for this file automatically.

At first I tried to go through Apache to get this working, but I'm no Apache guru so I was less than successful in taking this route. A couple of days ago I figured out a little trick to make the missing favicon.ico file stop sending me "broken link" e-mails hundreds of times a day. The solution? Put a favicon on my site, of course!

The approach I took was to simple add some information to my main urls.py file. Here's the line straight from my URLconf:

(r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),

Hah! Simple isn't it? This way Apache is still handling the actual serving of the static image file--Django just handles the redirect. Ever since I added this line to my URLconf, I've not received one "broken link" e-mail pertaining to the missing favicon.ico file. That leads me to believe that most applications can understand the redirect and plug the actual image file where it belongs.

Oh, and for those of you who might be curious... My favicon.ico is actually just a PNG image that I renamed to favicon.ico. Again, most things seem to understand this (but I could be wrong).

See below for a more complete example of my URLconf

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    (r'^admin/(.*)', admin.site.root),
    (r'^robots\.txt$', 'django.views.generic.simple.direct_to_template', {'template': 'robots.txt', 'mimetype': 'text/plain'}),
    (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),
    (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'base_home.html'}),
)

Slackware 12.1 on an Asus EeePC 701

Attention!

This article has a follow-up for Slackware 12.2.

The following are the steps I took to install Slackware 12.1 on my EeePC this past weekend. I hope you find them complete and helpful!

Installing Slackware 12.1 on an Asus EeePC 701

  1. Burn DVD .iso to disc
  2. Turn on EeePC
  3. Hit F2 to run setup
  4. Go to the Advanced tab, and set "OS Installation" to "Start"
  5. Go to the Boot tab, and ensure that the external DVD drive will be used for booting before the internal SSD
  6. Exit and save changes
  7. Just hit enter after rebooting from BIOS configuration when the Slackware boot screen shows up
  8. Unless you want to use a different keymap for whatever reason, hit enter when asked to select a keyboard map
  9. Login as root
  10. Run fdisk or cfdisk on /dev/hdc
  11. Remove all partitions (unless you know what you're doing)
    1. fdisk: d to delete (you may have to select multiple partitions to delete if you have more than one for some reason)
    2. cfdisk: Select all partitions individually with up/down arrow keys and use the left/right arrow keys to select delete from the menu at the bottom. Hit enter to run the delete command when it's highlighted.
  12. Create one partition that takes the whole SSD (again, unless you know what you're doing)
    1. fdisk: n (for new); enter; p (for primary); enter; 1 (for the first primary partition); enter; enter (to start at the beginning of the drive); enter (to select the end of the drive)
    2. cfdisk: Select the new command with the left/right arrow keys and hit enter when it's selected. Make it a primary parition, and have it take the whole SSD (3997.49MB in my case).
  13. Set the type of the new partition to be Linux
    1. fdisk: t (for type); enter; 83 (for Linux); enter
    2. cfdisk: Use the left/right arrow keys to select the type command at the bottom and hit enter when it's selected. Choose 83.
  14. Set the new partition (or the first, if you decided to make more than one) to be bootable
    1. fdisk: a (for bootable); enter; 1 (for primary partition 1); enter
    2. cfdisk: Select the bootable command from the bottom using the left/right arrow keys. Hit enter when it's selected.
  15. Write the changes to the partition table and quit
    1. fdisk: w
    2. cfdisk: Use the left/right arrow keys to select the write command from the bottom. Hit enter when it's selected. Type 'yes' to verify your intent, acknowledging that your previous data will be "gone". Then select the quit command.
  16. Run setup
  17. Select TARGET to specify where you will be installing
  18. Select /dev/hdc1
  19. Format the partition
  20. To reduce write cycles, many people suggest formatting with ext2, which is a non-journaling filesystem. However, many people claim that the limited number write cycles of SSD is not something to worry about. Use your best judgement on this one. Hit OK after the format is complete.
  21. Select where you plan to install Slackware from. In my case, it's the DVD. I usually tell it to find the media automatically. Select manual if you know which device your DVD drive is. Mine was /dev/sr0.
  22. Select the packages you wish to install. This is where your installation will likely differ greatly from mine because of personal preferences. I do a lot of development, so I will keep a lot of things for that. Here's what I selected to install:
    1. Base Linux System
    2. Various Applications that do not need X
    3. Program Development (C, C++, Lisp, Perl, etc.)
    4. Linux kernel source
    5. Qt and the K Desktop Environment for X
    6. System Libraries (needed by KDE, GNOME, X, and more)
    7. Networking (TCP/IP, UUCP, Mail, News)
    8. Tcl/Tk script languages
    9. X Window System
    10. X Applications
    11. Games
  23. Choose whether or not you want to be picky about your software. To save a little extra disk space, I'm going to manually choose what I don't want. This includes:
    1. A: cpio, cryptsetup, cups, floppy, genpower, jfsutils, mdadm, mt-st, mtx, quota, reiserfsprogs, rpm2tgz, tcsh, xfsprogs
    2. AP: amp, cdparanoia, hplip, gutenprint, jed, joe, jove, ksh93, mysql, rpm, xfsdump, zsh
    3. D: gcc-gfortran, gcc-gnat, gcc-java, mercurial, p2c
    4. N: elm, epic4, httpd, mailx, mutt, netatalk, pine, popa3d, proftpd, rp-pppoe, samba, slrn, tin, trn, vsftpd
    5. TCL: hfsutils
    6. X: anthy, bdftopcf, beforelight, libhangul, sazanami-fonts-ttf, sinhala_lklug-font-ttf, tibmachuni-font-ttf, wqy-zenhei-font-ttf
    7. XAP: audacious, audacious-plugins, gftp, mozilla-thunderbird, pan, seamonkey
  24. Wait for the installation to complete. It took almost a full hour with my package selection, leaving me with 485.4MB free on my 4GB SSD.
  25. Choose whether or not you want to make a bootable USB... I skipped it.
  26. Choose how you wish to install LILO. I chose simple.
  27. Choose your frame buffer mode for the console. I chose 640x480x256.
  28. Specify any optional kernal parameters. I left this blank, originally, but later learned that having 'hdc=noprobe' increased my disk access speed by about 13 times.
  29. Specify whether you wish to use UTF-8 on the console. I chose no.
  30. Specify where to install LILO. I chose MBR.
  31. Specify your mouse type. I chose imps2.
  32. Specify whether or not you wish to have gpm run at boot, which allows you to use your mouse in the console. I chose yes.
  33. Configure your network.
  34. Give your eeepc a hostname. This can be whatever you'd like.
  35. Specify the domain for your network. This can be whatever you'd like as well.
  36. Configure your IP address information. I just chose DHCP.
  37. Set the DHCP hostname. I left this blank.
  38. Review and confirm your network settings.
  39. Choose which services you wish to have running immediately after booting.
  40. See if you want to try custom screen fonts. I usually don't bother.
  41. Specify whether your hardware clock is set to local time or UTC.
  42. Choose your timezone.
  43. Select your preferred window manager. I chose KDE.
  44. Set the root password.
  45. Slackware has been installed! Exit the setup program and reboot.
  46. Hit F2 to enter the BIOS again.
  47. Set OS Installation to "Finished" and exit the BIOS, saving changes.
  48. Reboot into Slackware! The first boot takes a while because of all the initial setup. It is faster on subsequent reboots, assuming you don't add new services (like apache and mysql) at boot.

Change a few settings around.

  1. vi /etc/inittab
  2. (set default runlevel to 4)
  3. vi /etc/lilo.conf
  4. add 'compact' somewhere to make it boot faster
  5. change the boot delay so it's not 120 seconds

Now for installing various drivers.

  1. Install the ethernet driver: http://people.redhat.com/csnook/atl2/atl2-2.0.4.tar.bz2
    1. wget http://people.redhat.com/csnook/atl2/atl2-2.0.4.tar.bz2
    2. tar jxf atl2-2.0.4.tar.bz2
    3. cd atl2-2.0.4
    4. make
    5. cp atl2.ko /lib/modules/2.6.24.5-smp/kernel/drivers/net/
    6. depmod -a
    7. modprobe atl2
    8. ifconfig
  2. Install the drivers for the wireless: http://snapshots.madwifi.org/special/madwifi-nr-r3366+ar5007.tar.gz
    1. wget http://snapshots.madwifi.org/special/madwifi-nr-r3366+ar5007.tar.gz
    2. tar zxvf madwifi-nr-r3366+ar5007.tar.gz
    3. cd madwifi-nr-r3366+ar5007.tar.gz
    4. scripts/madwifi-unload
    5. scripts/find-madwifi-modules.sh uname -r
    6. make && make install
    7. modprobe ath_pci

I kind of stopped taking notes after I realized how much fun it was to have Slackware on my EeePC. If you have questions, just add a comment below.