Tallships

I work in (well, in an office next to) the Charlestown Navy Yard. I’d forgotten all about the Tall Ships event until they started docking.

Picton Castle

I haven’t been pleased with the photos I got, actually, largely because I’ve been carrying a bag with my work laptop and my camera bag every time I’ve tried to take photos thus far, plus the weather hasn’t been that great. But I thought I’d share a few for those who aren’t attending but who like boats.

Tallships by Night

Working until 9pm on Wednesday turned out to be a blessing. It was really nice and yielded some good photos.

Check out the whole gallery here.

Easy nofollow tags in Ruby (and Rails)

For a while I’ve been trying to ensure that all user-generated links on a site I code for had the rel=nofollow attribute to prevent giving spammers our link juice.

It’s a tough problem to solve, though. Or so I thought. I ended up doing a global search-and-replace (gsub) on any user-generated text, replacing " with " but this was broken for a few reasons. One is that, while apparently legal, it's bizarre to throw the rel attribute before the href attribute. Maybe that doesn't matter. The tricky part is that a link of the form http://www.example.com">; is totally valid, so I couldn't just match on or I would miss links from crafty users. The more I thought about it, the more it turned into a regular expression from hell. Plus, what if there was already a rel attribute, something like http://www.example.com" rel="faked_you_out">? I'd then put in a second rel attribute, which is bad. It was just spiraling out of control, and turning into a lot of code to handle a lot of weird possible cases.

A coworker nudged me in the direction of hpricot, an HTML parser. And suddenly, it was comically easy to do this flawlessly:

require 'hpricot'
html = Hpricot.parse(user_content_here)
(html/'a').each do |link|
   link['rel'] = 'nofollow'
end
return html.to_s

For each 'a' attribute, called 'link,' set its "rel" attribute to "nofollow". If there's already a rel attribute, it's replaced with "nofollow" and if there isn't one, it's added. hpricot handles all of the "special cases" that my code would have required. I don't care where the rel is at all in this. It just works.

How awesome is that? It seems to work flawlessly, and yet it's really basic code once you get past the somewhat unconventional format that hpricot uses.

Fixes

There’s this concept I keep running into that seems to have no word to describe it, but that happens all the time. The concept is opposing a fix to something because it’s not perfect. Let’s say that a whole city block was on fire, and the fire chief, having limited resources, commands his crew to start putting out the house closest to them.

“But chief,” a firefighter complains, “that won’t put out the other fires on the block. I think it’s a bad idea.”

“Well, then, what do you propose we should do?”

“I don’t know.”

I see this happen all the time in groups, and it invariably drives me out of my mind. It’s one thing when you have a better fix (“but chief, what about the other 7 firetrucks parked at the station and their crews that we forgot to dispatch to the fire? Let’s call them in!”), but all the time I see people shoot down an okay-enough fix to something, and propose no alternative, because the fix only improves the situation without fixing it entirely.

This isn’t to say that there are no bad ideas at all; if the chief’s recommendation was to spit on the house engulfed in flames, it would be a bad idea, because the improvement won’t be noticed at all. But if the fix is start by putting out one house, why not start there? Fire may be a bad example, since putting out the fire in a house if it’s surrounded by other burning homes will probably lead to the house catching on fire as soon as you move on. But take Ralph Nader’s opposition to seatbelt laws on the grounds that they didn’t go far enough. His opposition worked, but a better solution was never proposed, so he ended up undermining the cause he was fighting for. Or look at California’s budget crisis, in which two parties arguing over how much to cut the budget by end up deadlocked and the state ends up with no budget at all. If something is slow and someone finds a way to speed it up, but only a little, it’s an improvement. If you need a lot of money and someone gives you a little bit of money, it’s an improvement. Don’t say no unless you have a better plan.

This is a fairly ethereal concept, but it pops up everywhere. Watch for it and you’ll see it happen in short order, I promise.

Politics as Usual

This article makes me sick. If I try to distill the story down to a few sentences, I end up with a summary like this: some Republicans are trying to seize the opportunity to stick it to the Democrats by opposing Sotomayor, but other Republicans haven’t seen a good reason to oppose her. Still others think that they should give her carte blanche because she’s Hispanic and they don’t want to seem racist, or because the GOP needs stronger Hispanic backing. Some have blatantly confessed that they’re trying to figure out what would resonate most with voters.

Conspicuously absent in Congress, at least as told by this article, is any discussion about whether or not Sotomayor is a good candidate for the Supreme Court. Isn’t that all that matters? Stop discussing partisan loyalty, organized tactics to make your point, or race. If she’s qualified, approve her. If not, oppose her nomination and explain why you’re doing so. Is it really that hard?

(This isn’t at all meant to suggest that Republicans are alone in doing these things. They’re just the ones in the news at this particular moment.)

Literature Pop Quiz

I just described something as “rather the worse for wear,” and followed it up with, “Who was the person that described?” After receiving blank stares, I explained that I distinctly recalled those words being the last description of some literary figure (an author, not a character), but I couldn’t remember who and no one had any clue what I was talking about.

A quick bit of Googling backed me up. A well-known author was, indeed, described this way just prior to his death:

“[A] gentleman, rather the worse for wear… and who appears in great distress… I assure you, he is in need of immediate assistance.”

So pop quiz: who was the author described this way? No fair looking it up.

Preemptive Lying

A friend once told me a story about her troublemaker of a brother. One day, as a young kid, the dog came running into the house whimpering, and my friend’s brother immediately exclaimed, “I didn’t stab him!” Since no one had accused him of doing such, and since no one had yet realized that the dog had, indeed, been stabbed, his attempt at proclaiming his innocence ended up being a guilty plea.

It’s easy to dismiss as something little kids do, but I think the same sort of thing is happening in world politics. Every time North Korea releases a story about how great Kim Jong-il is doing, the fact that he’s most likely terminally ill becomes even more apparent. (And, by launching a ton of rockets into the ocean, they’re drawing still more attention to their leadership.) And you could say the same sort of thing about Iran: everything they say about being stable and thriving seems to be a pathetic attempt at denying the reality. Or like when the police investigating Rihanna’s beating had the police photos leaked to the press, and came out saying that they wouldn’t confirm whether they were real or a hoax, but that they would fire whoever leaked them to the press.

I’m a bad liar. The uneasiness in my voice and my panicked, paranoid look gives me away almost every time. But it sometimes seems that I can do better than the propaganda departments of some countries.

Cool Rails Links

Radiant CMS is a small CMS written in Rails that looks full-featured without being bloated. If I were to design a new semi-static site, I think I’d probably give it a whirl. It’s got quite a few extensions, too.

There’s also a Twitter gem that Rails (or just plain Ruby) developers can take advantage of. Without actually trying any, it seems that Fleakr may be the best available gem for Flickr. There’s also flickr-fu. Most irritatingly, the top gem, called “flickr,” seems like it hasn’t been worked on in a long time and never left alpha.

#unfollowfriday

I sometimes see people post on Twitter to the #followfriday category. Today I decided to go for #unfollowfriday.

It was a tough decision, honestly. I like the variety of what the people I follow on Twitter bring. Some are of a professional interest, others were of more personal interest to me, and still others were friends. But I have so much crap flying by on Twitter that I rarely even fire up a Twitter client because I just don’t care.

So I went for broke and removed most of the high-volume Twitterers I follow, along with a few that I never should have followed like snoopdogg. I hope I haven’t hurt anyone’s feelings, but I just couldn’t keep up with all of the tweets. Now I’ve got a pared-down offering so I can savor each tweet.

People will Soon Forget

Russian gas giant Gazprom formed a joint venture with Nigeria’s state-gas company, and chose to name their new venture Nigaz. Most people reading the news respond with, “Are you serious?!,” or just burst out laughing.

The BBC has an article about the poor choice, explaining that it’s not pronounced the way you might be tempted to pronounce it (but not in mixed company), and interviews a branding consultant who states, “People will soon forget that the name sounds bad.”

Really? People will soon forget that naming your African joint-venture “Nigaz” sounds offensive?

Home Fileserver?

What do the gurus think of this (barebones motherboard + Dual-core Atom 330), this case, and a pair of these? Oh, and go whole hog on the memory.

$335.45 for a PC-based fileserver with 2TB of disk, 2GB RAM, and minimal power usage. Put Linux on it and make it an iSCSI target, or use NFS. And Samba gives Windows clients support, too. Maybe you want something like Openfiler?

In an ideal world, I’d spend a bit more and have a machine with a “good” NIC (a high-end Gigabit card), hardware RAID (just basic support is fine), and three or more disks. But this is small and simple. I want to set it in a corner and forget it, and just mirror the drives via software RAID. Thoughts, anyone?