Archive for March, 2005

Blocking Popup Ads in Firefox

March 6th, 2005 by daryl

Blocking Flash popupsI had noticed of late that popups seemed to be coming through my Firefox popup blocker with some frequency. I was a little perplexed but didn’t give it much thought (it wasn’t that frequently). The other day, Asa posted something about it. Basically, rather than using javascript embedded in HTML, the guys who get through the popup blocker are using plugins (such as Flash) to open windows. Luckily, Firefox offers a way to stop these, but it’s turned off by default because turning it on blocks potentially valid functionality within the plugins. I’ve turned the option on, though, and here’s how (screen scraped from Asa’s blog):

To block pop-ups from plugins, open your Firefox 1.0 or 1.0.1 browser, type about:config in the address field. Right-click in the resulting config page somewhere and select New -> Interger. Type privacy.popups.disable_from_plugins in the resulting dialog, hit OK, type 2 in the next dialog and you’re all set.

This pref can actually take three values:

  • 0: open allowed
  • 1: the opened windows are treated as popups, but they’re allowed to open (we limit the number of these types of popups)
  • 2: the window is a popup, block it

In the image accompanying this entry, the preference is highlighted. This is the view you get when you enter “about:config” in the Firefox address bar (though yours won’t have the preference I’ve highlighted until you’ve added it). To add the preference, just right click anywhere in this screen and follow Asa’s instructions. So far, it’s worked great for me, and with no ill side effects.

Lives of the Animals

March 4th, 2005 by daryl

As noted elsewhere, much of what I’ve managed to write over the past few years has been animal-centric. When I showed some pieces recently to a former teacher and still-mentor of mine, he recommended a book by Robert Wrigley entitled Lives of the Animals. Because our themes are at times similar, I was keenly interested in reading the guy, but I found myself disappointed upon a first reading. I could tell he wrote skillfully and carefully; I knew that much of what he wrote was good. But it just didn’t resonate with me the way somebody like Andrew Hudgins does (especially in Saints and Strangers). I put the book down, a little disappointed.

The other day, a friend and former coworker whom I was talking to about doing some contract work for my company mentioned that he was involved with the Knoxville Writer’s Guild. I’ve known for years that the KWG was around but have never looked into the organization. Whether I neglected to do so because I figured they’d all be either hacks or schmoozers or just because I didn’t have time or energy I don’t know. At any rate, I perked up this time around and signed up for their mailing list. I almost immediately received notification of a reading by Marie Howe, one of whose books (What the Living Do) I had actually read in college. My reading the book started out as my thumbing through it because it had an interesting cover. I ultimately sat down and read it cover to cover, probably a couple of times. It’s a good book. Stoked at the prospect of going to the first reading I’ve been to in years, I wanted to read some more contemporary stuff, so I went back to Wrigley’s book the other night. And I liked it much more. It’s much stronger at the beginning and becomes a little droning toward the end.

Wrigley writes very tautly. There’s very little in his poems that doesn’t need to be there. And he writes with a sort of country elegance. I don’t mean that I fancy him to be a good ole Southern dandy but rather that he writes of the woods, of chasing snakes, of ticks on hunting dogs, of burning a dead horse, but he does so elegantly. His poems are smooth and flowing. They address rustic things but are themselves by and large not very rustic at all. It’s an interesting combination.

Wrigley writes in a very evocative way. Reading through the book, I felt constantly as if I was being reminded of things I had experienced. It eventually hit me that very few of the experiences he describes were ones I had first-hand knowledge of. In other words — and I think this captures one of the best things good poets do — he reminded me of things I hadn’t experienced as if they were very familiar to me, surely a testament to his talent at evocation and description.

A Simple Firefox Extension Build Script

March 3rd, 2005 by daryl

I’ve been working on building some extensions for Firefox, including my prawn doohickey and, starting today, something for work. When you build an extension, you have to follow a given directory hierarchy that’s pretty well documented here. You also have to zip up a couple of sets of files and rename them appropriately, move them around, etc. I’ve got a code directory set up that’s forked into a “src” (source) and an “xpi” (the file extension given to completed Firefox extensions) directory. I change files in the src directory and then build the xpi file and save it in the xpi directory. Initially, this was a pain because you have to edit the files, zip some of them, move some of them, zip something else, etc. And every time you make changes to an extension, you have to do this routine. After about three iterations of it, I wrote a quick little shell script that does the build for me. I just execute “./build” from the command line and it assembles the xpi for me. Here’s the build script:

#!/bin/sh

echo “- Removing old r2.jar.”
rm chrome/r2.jar

echo “- Zipping new r2.jar from content.”
zip -r r2.jar content skin locale
mv r2.jar chrome/

echo “- Creating xpi.”
zip -r r2.xpi install.rdf chrome/

echo “- Moving xpi to output directory.”
mv r2.xpi ../../xpi/

If I weren’t lazy, I’d make this portable so that I didn’t have to change the script for each extension, but for now, I can just do a regular expression and, in this case, replace “r2″ throughout the script with whatever the directory name for the current script is. I think you can actually use ant and an xml config file to build extensions, and for more complicated extensions, that might be in order. This seems to fit the bill pretty well for small ones, though.

The script assumes that the current directory contains an install.rdf file, a directory named “chrome,” and directories named “content,” “skin,” and “locale.” It zips the latter three directories into a file named (in this case) r2.jar, shoves that jar file into the “chrome” directory, and then creates a zip of install.rdf and “chrome” with the xpi extension. It copies this up into the xpi directory from which I open xpis to install them.

Early to Rise

March 3rd, 2005 by daryl

Wake up, look at clock, see that it’s 6:00. Get out of bed, pour big bowl of Honey Bunches of Oats with Almonds and start slowly munching it even though you’re not feeling the usual morning hungriness. Start reading email, check an ebay purchase you sort of inadvertently made and didn’t think you’d actually win but that it appears you may win after all. Note that the auction isn’t as close to being finished as you had thought it should be. Look at clock on computer screen and see that it is in fact just a little after 2:00. Find yourself puzzled. No wonder you’re not hungry. No wonder you’re still so frigging tired. Regretfully finish your bowl of cereal. Shuffle back into the bedroom. Sure enough, it’s just after 2:00 there as well. It was no clock malfunction. Climb back into bed.

Wake up, look at clock, see that it’s 6:00. Get out of bed, sort of hungry now. Still so frigging tired. It’s gonna be a long day.

Accessing PostgreSQL Remotely

March 2nd, 2005 by daryl

So I’ve been playing around with postgres for a week or so and this morning was finally ready to do an apache benchmark to test out how well it’ll work in something approximating a production environment. I ran mysql-bench on a comparable mysql database and tried to run it on my postgres database, but there were statements in the tests that postgres couldn’t handle, so it bombed. The really important test is how well the database works when behind apache, though, so I prepared my postgres database for such a test. As part of the benchmarking, I decided to separate the database server from the Web server so that load on one service doesn’t skew measurements of load on the other. So mysql and postgres are running on one box and apache’ll handle connections on another box that connects to the database box.

Some time back, I built a mysql database with four or five tables that are all pretty intimately related and that’ll see a lot of joins in production. I populated each of these with a million more or less random rows of data. Yesterday, I built a comparable postgres database and populated it with roughly the same dataset — the same size dataset, at any rate. Luckily, the Web service I had written to hit the mysql database used pretty basic queries that’ll work seamlessly in the postgres database. I had to add some code to my PHP database abstraction library so it could connect to a postgres database, but that was a cinch. So I get all that done and run some apache benchmarks on the mysql database. No problem. Then I change one value in my PHP file to make it hit the postgres database, and my connection times out, giving me an error like the following:

psql: could not connect to server: Connection refused
        Is the server running on host "server.com" and accepting
        TCP/IP connections on port 5432?

Well of course it’s running, I thought, because I can access it from the command line with no problem. And it’s definitely running on port 5432; when I rewrote the startup script to use the version of postgres I installed (in place of the old version), I actually remember verifying this. So I went to a terminal window on my local system and tried to telnet to port 5432 on the server. No bones. We’ve got a firewall running, so I checked the rules, and of course postgres isn’t in the default rules. I added it, restarted the firewall, and voila, I can telnet to the port. But I still can’t connect. This time, I get an error about the pg_hba.conf file not existing. It turns out that in postgres, you have to associate IPs with users and databases in this conf file in order to be able to connect remotely. Not a big deal. In mysql, you have to do something similar, though it’s in a user table rather than in a conf file that requires the server to be restarted after changes (just sending a SIGHUP didn’t do it for me, though it allegedly will). So I tested this out by adding my IP and user/database associations, and I can suddenly connect from my desktop. I added my server’s IP so that my pb_hga.conf looked something like this:

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               trust
# IPv4 local connections:
host    all         all         127.0.0.1/32          trust
# IPv6 local connections:
host    all         all         ::1/128               trust
# IPv4 remote connections:
host    all         dbuser    69.1.45.140/32        trust
host    all         dbuser    1.1.1.167/32       trust

But I still couldn’t connect from my apache box either through a PHP script or directly from the command line. It seemed to be timing out. Ah, but then I remembered that I’ve got a firewall on the Web server box too. I punched a hole through the firewall for connections going out from port 5432, and all of a sudden, my apache box can connect to and retrieve data from my database box. Woo hoo. Now I’m off to do the actual benchmark.

Lennie Update

March 1st, 2005 by daryl

Some things Lennie does now:

  • (At last!) Opens her mouth like a baby bird for food (not usually food spat from our mouths, though). She hasn’t really been a big eater to date. Well, she’s a big eater because she’s a big girl, but she prefers the magic boobies to solid or even liquefied table food. But she’s finally started to get the hang of it and will open up for pears, at least.
  • She doesn’t crawl yet, but she’ll sometimes get on all fours, most often in something close to the “up” position of a pushup, but with her butt all up in the air (the P.E. teacher would not be pleased). And she’s got a scooting radius of a yard or so, so she can definitely get around a little.
  • She holds things between her thumb and one or two fingers. This doesn’t seem like a big deal, but it is. She’s been doing it for a while.
  • Associates splashing with water. That sounds dumb, I know, so let me explain. She and Mleeka do a Wednesday swim class at which her primary activity (Lennie’s) is to intentionally splash the water. Babies naturally accidentally splash when they’re in the tub, but when she was in there the other day, she was splashing as if with intent, and it seemed pretty clear to me that she was thinking something like “hey, I’m in this wet stuff, and I smack the water with my hand when I’m in this wet stuff.”
  • Eats apples, carrots, and deli chicken. She really just sort of holds the chunks of apple and carrot we give her, shaving off little bits with her two bottom teeth. Giving her these little morsels has proven a handy way of getting through our own dinner without having to appease her or hold her.

There’s lots of other stuff, I’m sure. These’re just some of the highlights I wanted to capture before I forgot the general timeframe they occurred within.