Postings from 2006/10

CGI::Application under FastCGI

Oddness exhumed.

Just a quick note – perl’s CGI::Application::FastCGI , as of version 0.2, has a fatal bug that keeps it all but unusable – it doesn’t create a new CGI::Application object on each run, and objects get “stuck” in memory. It’s totally b0rked.

I don’t like the idea of changing my modules to use a different subclass for each persistent environment anyway, especially when the solution is as simple as a couple extra lines of code in your instance script. Below is an example instance script that works fine under FastCGI, and doesn’t require you to change your CGI::Application modules.

#!/usr/bin/perl
use strict;
use warnings;
use CGI::Fast;
use lib '/home/username/lib';
use ModuleName::Main;
my ($q,$app);
while($q=new CGI::Fast){
        $app=ModuleName::Main->new(QUERY=>$q);
        $app->run();
}

Russian "Earl Grey Smoky Tea"

Kusmi-Tea
Earl Grey Smoky Tea

Yup. That’s what the label says. “Smoky Tea”. It’s smoky. It’s black tea. It’s got bergamot oil.

Not your normal Earl Grey, and certainly not for those that don’t like the flavor of smoke. The smoke aroma is quite strong, equally as strong as the bergamot.

Brewed the “proper” way – preheated pot, boiling water over the leaves, 4 – 5 minutes or so for a steep – it’s quite good. It’d be nice if it had a bit more bergamot, but it still balances out rather nicely.

Two thumbs up! This would make a real interesting ice cream. . .

Safe HTML Whitelists

HTML Whitelisting in Ruby on Rails, the easy and safe way.

I’ve written a ROR helper (which ended up being relatively similar to this one) based on the “Easy HTML Whitelists” recipe in the Pragmatic Programmers Rails Recipes book.

The big problem with that recipe is that it allows any attributes on whitelisted tags. Not good. I could throw in nasty background images or cookie-stealing onclick/onmouseover events. XSS == teh badness.

Originally, I just stripped all the attributes, but in this post RoR Newbie asks “how can I allow SOME attributes?”

Thus was this helper born. It allows you to define “tag profiles” of allowed tags and attributes, and gives you the ability to allow different levels of sanitizing for different purposes/users. See the Rdoc for a fuller explanation.

Lemme know what you think. Dan at NOSPAMEendpoint dot com

HTMLFilterHelper

Rdoc:

http://www.kookdujour.com/doc/

The helper:

http://www.kookdujour.com/html_filter_helper.rb.txt

Try it out:

http://www.kookdujour.com/filter_test

More Nerd humor from Google Codesearch

Umm. . .

I don’t even know what to say about this.

Pretty soon you’ll be able to get Botox™ injections for your Civic™.

Recommend me on Working With Rails

Add to Technorati Favorites

Add to Google