Friday, September 26, 2008

"Time for Space Wiggle"

I've taken, by mistake, two photos of the same subject, at two slightly different angles.

As I was about to delete one of the photos I suddenly recalled a website I once stumbled upon - "Stereo Images - Time for Space Wiggle" (probably not safe for work - the site contains nudity) - which demonstrates how you can get a 3D effect by "wiggling" two images of the same subject, taken at slightly different angles...

So, without further ado, I give you Carnotaurus Sastrei:

bad breath


I'm no GIMP guru, but it wasn't too difficult to create this:
  1. open the first image in GIMP
  2. open the second image as a new layer (File->Open As Layers)
  3. scale the image to a reasonable size
  4. save as a GIF image, and when asked select the following: save layers as animation, loop forever, 10 milliseconds delay between frames
Boo!

Friday, September 19, 2008

Self Hosted: WordPress (multi-site)

Here's how to self-host your WordPress-based blog (oh, and please replace the stuff in red with your own stuff):
  1. install MySQL (e.g. by following the instructions in my previous Gallery2 self-hosting post)
  2. install WordPress
    aptitude install wordpress
  3. read /usr/share/doc/wordpress/README.Debian
  4. create /etc/apache2/sites-available/wordpress.example.com with the following contents:

    <virtualhost *:80>
    ServerName wordpress.example.com
    ServerAdmin webmaster@example.com
    UseCanonicalName Off
    DocumentRoot /var/www/wordpress.example.com
    Options All
    # Store uploads in /var/www/wp-uploads/wordpress.example.com
    RewriteEngine On
    RewriteRule ^/wp-uploads/(.*)$ /var/www/wp-uploads/%{HTTP_HOST}/$1
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log vhost_combined
    </virtualhost>
  5. create a link:
    ln -s /usr/share/wordpress /var/www/wordpress.example.com
  6. enable the new website:
    a2ensite wordpress.example.com
    /etc/init.d/apache2 reload
  7. setup the database with the following magic:
    bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress wordpress.example.com

  8. visit http://wordpress.example.com (your new blog!) and follow yet more instructions...

The Blogosphere awaits!

Friday, September 12, 2008

Self Hosted: Gallery2 (multi-site)

Please read the Gallery2 documentation, and follow the installation instructions. I did.

But these instructions are for a single Gallery2 site. I'm running three different Gallery2 sites, with different domain names (courtesy of No-IP.com) all from the same machine, all with an almost identical Apache2 configuration file.

Installing Gallery2 on Debian is rather straight forward, albeit somewhat tedious (please replace the text in red with your own stuff):
  1. run the following to setup the MySQL server:

    aptitude install mysql-server
    mysqladmin -u root password "password"
    skip this step if you already have a database server installed - and please read about securing the initial MySQL accounts.

  2. create a database for each Gallery2 site, and grant full privileges for this database to a specific user (provide this username, later on, to the web-based Gallery2 installer):

    mysqladmin -uroot -p create gallery2photos
    mysql gallery2 -uroot -p -e"GRANT ALL ON gallery2photos.* TO username@localhost IDENTIFIED BY 'password'"

  3. run (once)
    aptitude install gallery2

  4. create a configuration file for your site, e.g. /etc/apache2/sites-available/photos

    <VirtualHost *:80>
    ServerName gallery2.example.com
    ServerAdmin webmaster@example.com
    <IfModule mod_rewrite.c>
    RewriteLog /var/log/apache2/rewrite.log
    RewriteEngine On
    RewriteRule ^/$ gallery2 [R]
    </IfModule>
    DocumentRoot /var/www/photos
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    Alias /admin/gallery2 /usr/share/gallery2
    <Directory /admin/gallery2>
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
    </Directory>
    <Directory /gallery2>
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
    </Directory>
    ErrorLog /var/log/apache2/error.log
    LogLevel warn
    CustomLog /var/log/apache2/access.log vhost_combined
    </VirtualHost>

  5. enable mod_rewrite:
    a2enmod rewrite
    the idea is that access to http://gallery2.example.com will automatically be diverted to http://gallery2.example.com/gallery2 (this is a dedicated photo album website)

  6. create a directory for your Gallery2 website:
    mkdir -p /home/username/www/photos/gallery2

  7. create a symlink /var/www/photos to the root directory of your Gallery2 website:
    ln -s /home/username/www/photos /var/www/photos

  8. set the directory ownership:
    chown -R www-data:www-data /home/username/www/photos

  9. create a directory to host the Gallery2 data and images (e.g. /home/username/g2data/photos - you'll be prompted to do this as part of the web-based Gallery2 installation procedure)

  10. enable the new site and restart the webserver:

    a2ensite photos
    /etc/init.d/apache2 restart

  11. open the following link in a browser: http://gallery2.example.com/admin/gallery2 and follow the web-based installer instructions... (you should also read the multi-site installation instructions)

Tip: when uploading new photos to Gallery2, that are already on your computer, you should use the "From Local Server" tab in the "Add Items" web page, and tick the option "Use symlink" for each photo that you upload. This keeps a single copy of each image on your computer, and separates the photos from the Gallery2 files.

Friday, September 5, 2008

Awesome!

Sometime ago I said that I intend to move from GNOME to an alternative, keyboard-centric tiling WM (Window Manager). Any such change requires some getting used to. Any such WM has its own philosophy regarding both its users and what it means to manage windows. Each of these WMs has its own set of default key bindings and different methods of configuration. That's the problem with freedom: one has to choose.

In my case I find that I'm most comfortable when every application window that I use is maximized to span most of the screen area. Sometimes I split the screen between two applications windows, usually horizontally. I also want (but I don't need) a simple status bar at the top of the screen, showing (at least) the name of the active window, some info (date/clock, load average) and maybe tray icons. Oh, and I want to still be able to run applications in floating-windows mode just like any other (read: normal) WM (the GIMP is probably the ultimate test here).

I attempted to get this behavior in GNOME using Devil's Pie - a cool little WM-like utility that lets you control window behavior using lisp-like scripts. For example, I made urxvt always open up maximized, without any window decorations, using the following Devil's Pie script ~/.devilspie/urxvt.ds :

(if (is
(window_class)
"URxvt")
(begin
(maximize)
(undecorate)
(focus)))

But don't be misled by the appearance of this .ds script: this is not a real programming language (no loops, no functions, no variables). Furthermore, Devil's Pie does not manage windows - it only serves as a startup hook that's applied to windows upon being first displayed. This just wasn't good enough for me.

This is actually my second round of WM evaluation. Last time was almost 3 years ago, at work - I was in a process of reinventing my work environment. Heck, I even tried using vim for two weeks (definitely not for me, thank you very much :q!). Eventually, I narrowed down my options to larswm, ion3, ratpoison and wmii. I ended up running an early release of ion3, heavily customized to do my bidding, together with a custom keyboard setup.

This time around I was shopping for a WM for my old laptop at home. I wasn't going to try ion3 - it's not in Debian testing, and may never be, due to its moronic non-free license. It was the most polished and stable WM of its kind, at the time. But there are better options these days. Plus, I was looking for a setup that would work almost out of the box, with little or no customization. I just couldn't stand the frustration of re-customizing my setup after each major release of the WM (I solved the problem at work by not upgrading ion3, can you believe?).

So I started using ratpoison at home, even though I knew it does not support floating windows, because, apart for that, it seemed to fit my usage patterns like a glove. I hit a dead-end though when I tried running some Window$ applications using Wine - there were some serious issues there (e.g. I could not select multiple files in the Window$ standard file-open dialog box). And, as much as I pretended not to, I really did need the WM to support floating windows. I simply had to switch over to a different WM.

I tried stumpwm, which is written in Common Lisp, by the same guy who wrote ratpoison, based on the same concepts. So cool. So flexible. And oh so very slow. It takes almost two minutes (!) for it to load on my old laptop. Not cool. Ah, and it does not support floating windows.

This meant one thing: I had to leave the comfort of static tiling WMs and go dynamic. With a static tiling WM, like ion3, ratpoison and stumpwm, you can arrange window layouts in advance, and place and move windows from one part of the layout to the other. A dynamic tiling WM arranges windows on its own, based on one or more layout algorithms.

I considered wmii: I tried it several times in the past, and was impressed by the underlying architecture and concepts (window tagging, floating layer, etc.). I was, however, repeatedly put off by its instability. I believe I sampled v2.5, v3.2 and v3.5, but I have no records to prove this. To be fair, it's been a while, so maybe things are better now. I decided to skip it anyway.

I tried dwm when it first came out. It was written by wmii's original author, after he got fed up with its complexity. It was very easy to pick up, very minimal, fast - quite cool. Well, not really - dwm can only be configured by editing its C source code and recompiling it. While it can be argued that this isn't too different than writing Lua scripts for ion3, it still feels wrong. Add to that the author's little fetish: one of his major goals is to pack the WM into as few lines of source code as he possibly can. I never bothered to follow its development. Next.

How about XMonad? it's written and configured in Haskell, which I don't grok. For a while, after it came out, it looked like The Great White Hope of tiling WMs: a lively, fun project, with a lot of features planned for the future, no ties to existing code, with some great coders hacking it, an ever growing number of contributed extensions, and a core code-base that is provably correct. It also seemed like a good opportunity for me to get into Haskell - I've been hearing about it all over the 'Net, and I wanted to see what the fuss is about.

It must be said that XMonad requires very little Haskell in order to get up and running, but in my mind using this WM meant getting knee-deep into Haskell. But between a day job, a growing family and this blog, it soon started to look daunting - I decided I should probably see what else is out there, dismiss the other WMs, go back to XMonad, and then put effort into it. I figured that by then it would mature and that its support for floating windows would improve.

Enter awesome - it started as a fork of dwm, but soon became a completely different WM. It has built-in, proper support for floating windows, built-in status bar, a simple configuration file (the upcoming version 3 has switched to Lua scripts), wmii-style window tagging system, built-in support for Xinerama (which I don't use) and a lot more. While the authors of most of the other tiling WMs attempt to achieve some form of technical purity, the stated goal of awesome is for it to simply be an awesome WM.

And it's on the right path.

During the first few days of using it (version 2.2) I would hide the status bar and work in max-mode - the effect was very similar to my ratpoison experience. I then started using the status bar, and configured some rules for window tagging and keyboard shortcuts, to support my usage patterns.

It's the only WM of the pack that supports anti-aliased fonts, via the Pango text layout and rendering library (since version 2.3). Pango also provides bi-directional text rendering - so that window titles are correctly rendered, even if Hebrew text is included.

Version 3 will include some major changes - Lua for extension scripting, status bar enhancements (tray icons!), tabbed windows and a lot of internal changes that suggest that awesome will be even more awesome than it already is.

So awesome is my WM of choice for the foreseeable future. As for Haskell - well, it seems that I need a different excuse for learning it.