Archive for December, 2005

An Eerie Continuum

December 23rd, 2005 by daryl

An eerie continuum

I’ve long had a theory about the inter-relatedness of the characters depicted here. Somewhere in the mix, I think there’s room for Gorbachev and a jar of grape jelly.

Loyal Opposition

December 21st, 2005 by daryl

A discussion mailing list I belong to has flared up this week over US politics having to do with Iraq. Liberals continue to cry out indignantly about the injustice of the war; conservatives continue to suggest that the war was justified and that liberals are appealing to emotions rather than to facts for their positions. I stay out of the discussion for the most part because I think being informed enough about the matter from unbiased sources is pretty much impossible for average Joes, so my input is only so valuable. But when somebody posted the following message, I had to respond.

There was a vote in the House on Friday. The vote was on H Res 612 “Expressing the commitment of the House of Representatives to achieving victory in Iraq.” Believe it or not, 108 Democrats voted no. Think about it, 108 Democrats are now on record as opposing victory in Iraq. There’s your “loyal” opposition…

http://clerk.house.gov/evs/2005/roll648.xml

And here’s how I responded:

Try reading the resolution. The summary you provide is one of eight major points, several of which I can see people not being comfortable voting for. You can read the full text at http://thomas.loc.gov (it’s a short resolution and an easy read). [Note that I actually pasted in a URL that didn’t work b/c of the way the site handles search queries; to get the actual bill, go to the url linked and do a search on “HR Res 612″.] Problem clauses to my mind include at least the following:

  • setting an artificial timetable for the withdrawal of United States Armed Forces from Iraq, or immediately terminating their deployment in Iraq and redeploying them elsewhere in the region, is fundamentally inconsistent with achieving victory in Iraq;
  • the House of Representatives has unshakable confidence that, with the support of the American people and the Congress, United States Armed Forces, along with Iraqi and Coalition forces, shall achieve victory in Iraq

In the first case, many representatives have already expressed opinions to the contrary and so couldn’t vote yea on this resolution in good conscience. In the second, it seems clear that many representatives think we’ve botched this thing and that there’s not “unshakable” confidence that we’ll win. It’s a stupid resolution whose aim is to make those voting against it look bad by putting them in a corner so that they feel as if they have to vote for it or look like they’re not in favor of victory because that’s the controversial point everybody’ll zoom in on.

Highlighting the one point without even acknowledging that there are others that might complicate things strikes me as being pretty dishonest. I’m sure there are many conservative pundits and propagandists who’re doing just this sort of thing. Sadly, liberals do it too.

The moral, of course, is that headlines and blurbs don’t tell the whole story, and you can’t usually trust either the left-wing or the right-wing source from which you got a given controversial snippet.

Google Knows All

December 19th, 2005 by daryl

The home page in my browser is set to Google’s personalized home page, which aggregates gmail messages, headlines from various sources, weather, a word of the day from dictionary.com, etc. You can set what you want it to aggregate. Among other things I get a list of top stories from various sources and the word of the day. This interesting juxtaposition appeared today. I wonder if dictionary.com is editorializing or if the words of the day are generated randomly and this is pure chance.

189

December 17th, 2005 by daryl

Sorry, Mike, but I seem to have misplaced most of those 13 pounds you asked me for. I’m down nine more pounds in the last three or so weeks. A week gorging myself in California oddly enough always seems to drop five or so pounds. Then I spent a week not eating much at all thanks to the plague that struck my family. Now I’m back more or less on track and am down to 189 after a two-week absence from the gym. The once-thought-unattainable college weight is four pounds away. Oddly, I think I’m still technically obese or borderline obese. I’d like to get my body mass index down to a reasonable range, and so my new goal is to drop to 170ish.

Don’t worry, I’m not wasting away or anything. I still have a pretty substantial girdle of fat around my midsection along with some fat I’m paring slowly away from my upper arms that I think will account for most of that. Once I hit or get fairly close to my goal, it’ll be all about maintaining and not about losing anymore.

That’s a 51 pound drop since September 3, when I began chronicling my weight loss. I’ve lost more than 20% of my body since then. That’s two toddlers, or a third of an average-sized man. I’m four-fifths the man I used to be.

She Likes Me! She Really Likes Me!

December 16th, 2005 by daryl

What a couple of weeks. Last Monday, I caught a 5:00 a.m. flight out to San Francisco to spend a few days with the crew at work. I spent four full days out there and then caught an 11:00 p.m. flight to Charlotte on Thursday. Dad picked me up at 6:30 a.m. at the airport, and I went to his house, to which Mleeka and Lennie had driven while I was out of town. From the time she saw me, Lennie very desparately wanted to be with me. I’d head upstairs to grab something and she’d shuffle over to the gate and dolefully cry “Daddeeeee, Daddeeeee” up the stairs until I came back. It was heartbreaking because I felt that she now maybe worries that when I leave, I’m not coming back, but it was also validating and nice.

While we were there, Mleeka got sick (a stomach bug that’s going around Knoxville). We came home Sunday afternoon, and I spent all night Sunday night throwing up and spent most of Monday in bed. On Tuesday, I got back to work. Periodically, Lennie would come to my office door and bang on it (as she sometimes has for months now), but now she adds to the equation her doleful “Daddeeeee,” which it’s just impossible to resist. To top if all off, she’s gotten sick as well. She had a high (103+) fever on Tuesday night and has been up and down for the past couple of days. She threw up a couple of times on Wednesday and was droopy for much of yesterday but appears perhaps to be coming out of it now. While she was sick, there were times during which I was her sole comfort, though. A couple of days this week, she’s lain prone on me for a half hour or more at a time in the middle of the day, and she’s been clinging to me (and recoiling from Mleeka) in a weird reversal of the usual routine.

Now Mleeka gets a glimpse of what it’s been like for me for 18 months, though really, it’s worse for her because, while I’ve been sort of resigned to it and expected nothing different, it’s a new change for her. I’ve been shunned and have found being occasionally wanted to be a nice surprise; she’s been wanted and is now being shunned. I’m sure that once Lennie figures out that I’m actually not leaving for good or anything, her disposition toward Mleeka and me will shift back closer to its normal ratio. In the mean time, it’s nice (if not terribly pragmatic from the standpoint of having to actually get work done) to be wanted.

Multi-site functionality in Drupal

December 14th, 2005 by daryl

I think I’m going at last to stop qualifying tech posts with the usual “don’t bother to read this if you’re in my family because you’ll probably find it pointless and really quite a snoozer” disclaimer. Basically, if it’s marked tech with no other categories or tags, it’s probably going to be of limited interest to most of my family.

For both work and another site I’m playing with right now, I’m using Drupal and have a need for multi-site functionality with separate content but shared users. I tried setting this up a year or so ago at spreadfirefox.com and it was anything but ideal. Things have gotten better since then, but they’re still not perfect. Here’s how I got this to work after consulting various Drupal forum posts.

1. Copy the default config. In the sites directory, copy the “default” directory and paste it in as the domain name you wish to multi-home on this Drupal install. If default/settings.php is configured to host domain.com and you wish also to host abc.domain.com, name the new directory “abc.domain.com”.

2. Tweaking per-site settings. Edit settings.php. First, change the $base_url value to match the new domain (in this example, it would read “http://abc.domain.com”). Then edit the $db_prefix variable. If the variable is a string, Drupal’s engine prefixes the string to all database tables before running queries. If it’s an array, you can define per-table prefixes. This is really the heart of the multi-homing capability, as you’ll want to share some tables but not others. Here’s the setup that has worked for me:

$db_prefix = array(
‘default’ => ‘abc_’,
‘authmap’ => ”,
‘profile_fields’ => ”,
‘profile_values’ => ”,
‘role’ => ”,
’sequences’ => ”,
’sessions’ => ”,
‘users’ => ”,
‘users_roles’ => ”
);

In my case, I had already created all of my tables with no prefixes. Thus for the shared tables, I set the prefix to a blank string so that those tables get used. For all tables not listed explicitly in the array, the engine falls back to the default value, which I’ve set to “abc_”. So all tables listed here (non-content tables) are shared, and all others have to be created with the appropriate prefix (”abc_”).

3. Editing table names. I found the following script somewhere in a Drupal forum thread:

#!/bin/sh
usage(){
cat - <<EOF
cat database.sql | `basename $0` prefix1 | mysql
EOF
}
[ “$1″ == “-h” ] && usage && exit
[ -z $1 ] && cat && exit
PRE=$1
sed “s/\(TABLE\|INTO\|FROM\|REPLACE\) /\1 ${PRE}_/g”

Copy it into your database directory in your Drupal install. Make sure it’s executable (”chmod u+x convert” where “convert” is whatever you named the script). Then execute “cat database.mysql | ./convert prefix > prefix_database.mysql” where “prefix” in both instances is the alphanumeric database prefix you provided in the “default” slot for your $db_prefix above. In my case, it would be “abc”. This will create a file that you can slurp into mysql using your favored method.

But before you do so, you’ll probably want to hand-edit it a bit. It’s not essential, but for the sake of reducing your number of tables, it’d be ideal. Basically, for the tables you’re sharing as listed in $db_prefix, delete the create table statements and any other statements associated with those tables. If you’re creating many sites, I recommend doing this once, then using vim to edit subsequent copies and doing a regular expression to substitute values.

4. Manual database tweaks. Here I’ve had to do some manual tweaking to make things work properly. I’m assuming that your initial site already has some configuration values set up that you’d like to clone to your new sites. This was the case with my setup, at least. Some of these steps may not be necessary if this isn’t the case.

  • DELETE FROM abc_variable
    Get rid of potential duplicates that may arise for the next step.
  • INSERT INTO abc_variable SELECT * FROM variable
    Clone your initial site’s variable settings into your new site.
  • DELETE FROM abc_permission
    Get rid of default permissions
  • INSERT INTO abc_permission SELECT * FROM permission
    Clone your initial site’s permissions into your new site. If you’ve already set up permissions in your initial site, this brings them into the new site so that you don’t have to redefine them. They’ll diverge from this point onward. You could also just share this table by adding it to $db_prefix above.
  • DELETE FROM abc_system
    Get rid of default system settings
  • INSERT INTO abc_system SELECT * FROM system
    Clone initial site’s system settings. This and the previous step may not be necessary, but they seemed to help out with a theming issue I’ll get to momentarily.
  • DELETE FROM abc_cache
    Weird things happen if you don’t do this after some of the other steps.

Even after doing these things, you may run into some weird issues with the theme. I think the sequence I’ve provided above resolves these, but if not, just get logged in as admin, make sure your theme engine is set correctly in the new site, and make sure a theme that uses that engine is selected. In my case, weird theme issues had to do with the fact that the phptemplate theme engine wasn’t enabled but a theme that used it was. I believe tweaking the system table as described above helped me resolve this.

5. Miscellaneous. There are other things you might consider sharing. Taxonomies, for example, might be something you’d want to share across sites, though in my case, I want site admins to be able to define their own distinct taxonomies.

I’m sure doing this sort of modification kills the upgrade path and makes it harder and harder to maintain upgrades as you get more and more multi-homed sites. Fair warning.

Be careful with permissions. Test any changes, as you may or may not be giving permissions for some users to do things across sites (if you share the permissions and users_roles tables, for example).

I hear you can specify database names in addition to table prefixes in $db_prefix if you’d like to select across databases. The syntax here would be “database.abc_” rather than just “abc_”.

That’s it. After following those steps per site under my setup using Drupal 4.6.5, I’ve got four sites (a main and three subdomains) all using the same user database but with different content. If I’m logged into one, I’m logged into them all, so I can participate in different segments of the community without having to manage multiple logins. It’s pretty nifty.

GROUP_CONCAT

December 6th, 2005 by daryl

I’m working on a community dashboard for work that’ll help me monitor different ways in which people are interacting with the community. One metric I thought it’d be neat to have was how many people have filed more than X bug reports during the last period Y (month, say, or week) and what the average for that period over time has been. This involves a pretty complicated query wherein you have to group by both user and period, which is kind of tricky. It’s also very expensive: With only about 1200 bugs in our database, this query was taking six seconds when I was testing it out. That’s clearly unacceptable. So I poked around a bit and discovered the GROUP_CONCAT function, which lets you group by one column and output the relevant grouped data in a delimited column. So say your query is something like this:

select DATE_FORMAT(creation_ts,’%Y-%m’) date, group_concat(reporter) cnt from bugs group by DATE_FORMAT(creation_ts,’%Y-%m’)

Here I’m getting all months in the database and a listing of all reporters of bugs for that month. The “cnt” column is a comma-delimited lists of user ids for those who reported bugs in the given month, duplicates included (though you can specify DISTINCT to eliminate duplicates). The query returns almost instantly and gives me something I can parse pretty easily in the programming language of my choice.

In my case, I split the “cnt” column on commas for each result and tally the ids for users who appear in the list X or more times. I then pass this data back to a function that does math to get averages and to find a count for the current month, and voila, community metrics.

I blog this here because it’s the sort of thing I might want to remember later, and I always put that stuff here rather than at my work blog, where my regular readers probably figure this should actually go.