Popyula: A Blogosphere Popularity Report 1

Posted by Tadman Wed, 11 Oct 2006 02:36:00 GMT

After a week of steady work I’m finally able to launch my first quick application: Popyula, a site that reports on the ever changing popularity of pages as they appear in blogs.

Right now it’s covering Digg and Reddit but that will be expanded to other popular services in the near future.

For example, here’s a list of all links to YouTube.

While I haven’t gone so far as to slap the Web2.0 requisite “Beta” decal on the site, it is a work in progress.

What’s great is that with Ruby on Rails, Mongrel and Apache 2.2 I was able to make this run really fast on a really low-budget server.

Quick Ruby on Rails SQL Shell Tool 25

Posted by Tadman Tue, 10 Oct 2006 20:30:00 GMT

This is a simple Ruby script that I put together to launch a MySQL shell for a rails application. It looks within the current directory and parent directories for a database.yml configuration file to read.

#!/usr/bin/env ruby

require 'yaml'
require 'optparse'

config = nil

path = "."
while (File.exists?(path) and (path.length < 255) and !config)
        if (File.exists?("#{path}/config/database.yml"))
                File.open("#{path}/config/database.yml") do |f|
                        config = YAML.load(f)
                end
        else
                path = "../#{path}"
        end
end

unless (config)
        puts "Could not find database.yml"
        exit(-1)
end

command = "mysql"
verbose = false

opts = OptionParser.new
opts.on("-v", "--verbose") { verbose = true }
opts.on("-d", "--dump") { command = "mysqldump" }

args = opts.parse(*ARGV)

environ = (args[0] or ENV['RAILS_ENV'] or 'development')

if (config and config[environ])
        config = config[environ]

        puts config.inspect if (verbose)

        exec(command,
                "--user=#{config['username']}",
                "--password=#{config['password']}",
                "--host=#{config['host']}",
                "--port=#{config['port'] or 3306}",
                config['database']
        )
elsif (config)
        print "Could not find environment #{environ} in configuration file\n"
        exit(-2)
else
        print "Could not find or read Rails configuration file\n"
        exit(-1)
end

For example, to save a database backup:

% cd svn/myapp/db
% rsql --dump > dev.sql

Ruby on Rails Migrations 3

Posted by Tadman Tue, 10 Oct 2006 18:50:00 GMT

Although I’m a big fan of the concept of migrations, one of the things I’m not especially enamoured with is the way Rails implements them. Each migration is an atomic thing that proceeds, in specific sequence, from others. There’s no room for branching or conditions.

When I’m working in a group development environment I might be producing code that requires a migration alongside another developer doing much the same. Without some degree of co-ordination regarding migration numbers, this will cause a conflict, even if the actual migrations themselves are entirely independent..

It would be nice if the migrations had not only some kind of sequence identifier number but a prerequisites column so that two could share a number and yet be applied correctly.

I wonder if developing an improved migrations system would yield any tangible benefits.

Mongrel Rails Launcher 4

Posted by Tadman Mon, 09 Oct 2006 04:01:00 GMT

Here’s a quick init.d-type script to launch Mongrel with the appropriate options:

#!/bin/sh

case "$1" in
        start)
                mongrel_rails start -d -e demo -p 4101 -P log/mongrel-dev.pid
                ;;
        stop)
                mongrel_rails stop -P log/mongrel-dev.pid
                ;;
        *)
                echo $"Invalid option"
                exit 1
esac

This is useful if there’s more than one instance of mongrel running in a particular directory.

Subversion 1.4 and Apache 2.2

Posted by Tadman Sat, 07 Oct 2006 23:20:00 GMT

The Apache development team has upgraded the apr interface for httpd from version 0 to version 1, where httpd-2.2.3 is now using apr-1.2.7.

This means that a lot of modules not only have to be recompiled, but they need to use the correct apr or they’ll be left hanging.

I thought I had compiled it correctly but I was using the wrong one, as an upgrade from 2.0 to 2.2 had carelessly left them behind.

This is how I got it to hold together on a Fedora system:

./configure --with-apxs=/httpd/bin/apxs \
 --with-apr=/usr/local/apache2/bin/apr-1-config \
 --with-apr-util=/usr/local/apache2/bin/apu-1-config

Disabling Caps Lock on OS X 4

Posted by Tadman Fri, 06 Oct 2006 23:14:00 GMT

Eclipsed perhaps only by the regretful Windows Key, “Caps Lock” is a perpetual nuisance on many keyboards. It exists merely to annoy.

The Matias keyboard I have doesn’t put the button in its usual place, instead opting to tuck it away down by the right Control key. There it is less of a pest but it will still get bumped and nudged from time to time.

The best way to eliminate this button altogether, short of prying it from the keyboard, is to map it out using the Keyboard control panel.

Broadband SMTP Blockade Workaround 2

Posted by Tadman Thu, 05 Oct 2006 17:43:00 GMT

A lot of broadband providers have taken to outright disabling port 25 access to the outside world, effectively killing off SMTP for anyone who’s not using their official servers. Unfortunately these servers are often restricted and only allow e-mail to be sent if it is originating from an address at their domain.

If you have a remote server, though, you can always set up an alternate port for your SMTP service. For a while I’d been using iptables rules to manage this, but there’s an even easier approach: rinetd.

This is a very easy thing to install, no configure even required, and once in place can easily map ports any way you wish.

A sample /etc/rinetd.conf might be as follows:

0.0.0.0 20025 127.0.0.1 25

That’d map external port 25025 to internal port 25 where your SMTP server is presumably listening. Then it’s just a case of configuring your e-mail client to use the new port and you’re off and running.

Better yet, if you have a local machine which can run rinetd, you can add something similar to work around even that, in effect pretending you have a local SMTP server by having this configuration:

0.0.0.0 25 smtp.mydomain.com 20025

Now I have no trouble at all sending mail from any e-mail address I might need to use.

Server Drudgery 3

Posted by Tadman Thu, 05 Oct 2006 03:29:00 GMT

If there’s one area where OS X totally spoils me it’s how easy it is to install software. For native applications it really is as simple as drag-and-drop, and often simpler still where you can run right from where it was downloaded.

On Linux there’s no such thing as an “easy install”. Even the most modern of package managers involve typing, waiting, wondering, and then a whole lot of poking and testing to make sure everything went according to plan.

Gentoo’s portage system is actually pretty nice but still has some rough edges. Since it installs from source, you end up watching a whole lot of compiler nonsense scroll by with no real indication as to what’s happening. “Something is being compiled. Please wait.”

Granted OS X has been designed with ease of use in mind practically from the ground up and Linux has evolved from a system not known for having any degree of friendliness at all, but surely there’s a reason to pave over a whole lot of what makes Linux ugly so that it’s easier to get your job done.

Switching from Lighttpd + FCGI to Apache + Mongrel took the better part of five hours today and that was mostly because of all the dependencies involved. The old Apache 2.0 wasn’t good enough, it had to be upgraded, and since the Apache group renamed their modules, the old configuration file had to be fixed, too.

To make matters worse, Gentoo has an ebuild for httpd 2.2 but the configuration file in the bundle is from 2.0 and doesn’t work. Thanks. No wonder it’s masked. I need mod_proxy_balancer so I can’t really choose to use 2.0.x.

Too much information, I know.

Is it too much to ask that things just “work”?

READY 3

Posted by Tadman Thu, 05 Oct 2006 02:53:00 GMT

It might take a while to get this site up to speed, so many bits of technology to wrangle into their proper place, so for now it’s all on manual. To be truly retro, this should be some kind of Lynx page, but even green on black can get all too ridiculously cliché which is why this site features a refreshingly different neon green on gray theme to break from tradition.

First post and already it’s a matter of semantics.

With technology charging ahead so quickly, it seems like we’re powerless to catch up to it. There was a time when ”640K should be enough for anyone” seemed like a reasonable statement to make, but now people are left wondering what they’ll do with all that hard drive space in their new computer. At least until it’s full of podcasts, along with other, shall we say, material.

We’re at the point now where six months ago is retro.