Geekery and Beer

So, I’m sitting here drinking some of my new homebrew. It’s a rather nice cherry wheat that came out a tad more spicy than I was actually expecting. I think I rather overdid it on the cinnamon. I figure that after another couple of weeks of bottle conditioning, it might turn out to be a rather good beer.

One thing I have noticed is that it’s a lot stronger than I was expecting. After just one, I’m catching a buzz. Very nice.

Anyway, while I’m basking in the sun and enjoying a frosty beverage, I figured I’d putz around with the website a bit. Those of you of a geekish bent might try looking at the site on your mobile phone or whatever handheld device you happen to prefer. Through the magical power of the interwebs, the blog should now look different on the handheld devices, more suited to smaller screens. It’ll eliminate the sidebars and rejigger the display a bit. Since I’ve been using the mobile web a lot more, I find this quite cool.

Also if, for some demented reason, you feel it necessary to produce hardcopy of my random meanderings, you’ll find that the excessive imagery disappears on the printout, leaving you with just the basic text and little else. This should all be automatic if you have a modern browser, no strange trickery required. Although I’m dubious as to why anybody would want to print out my worthless words, the option is now there, if you happen to come up with a reason.

Those of you interested in the technical details can read on after the jump…
Continue reading “Geekery and Beer”

HOW-TO: Make WordPress Blogroll's smarter

Warning: Heavy geek content ahead. If you’re not interested in PHP code, you can safely skip this post.

One thing that not a lot of people know about is that WordPress is capable of checking your bookmarks/blogroll links for you and organizing them according to the time they were last updated.

The reasons people don’t know this are:
a) It’s not automatically setup and working, and
b) It rarely works in the first place.
Continue reading “HOW-TO: Make WordPress Blogroll's smarter”

Death of a PC

My home computer did not survive the move. It appears fine at first glance, however the power supply seems to have taken some sort of fatal injury. This is a non-trivial fix (as it’s a pretty heavy duty power supply), so I’ll be offline for quite some time while I repair or replace it. Not looking forward to that, just getting it out of the case is major surgery.

On the plus side, everything else has gone really well. If I can finish getting all my stuff out of the apartment this weekend, and then finish unpacking, I should be good to go. I really like the new condo.

Post-vacation weariness

I’ve been unable to think properly for the last week and a half since coming back from St. Pats. Because of this, I’ve sorta slacked off on posting pictures and such. Also, I didn’t take my camera to St. Pats (because I’m an idiot), so I’m just really waiting for everybody else to send me their pictures and thus I can create a compilation.

Still, I have some newer pictures, so I may as well post those instead.

Last week, Mike and Paola had a beer tasting party. It was a hell of a good time, and I’d like to thank them for having it. I look forward to brewing a bunch of new beers up for the next one. They posted some pictures, which I shamelessly stole and stuck into my own web album because this lets me keep things in one place.

On Sunday, we were having brunch at the Majestic, when Mikey gets a call, walks outside, and comes back with a plastic light-up Spuds MacKensie. Naturally, we had to take him on a tour of the town before returning him to his rightful owners. Mikey has more pictures than I do, these were taken using my cell phone, which I’m getting better at using nowadays.

So that was last weekend. I missed Trivia night at the Saucer last night, because a) I was really tired, but mainly because b) I was actually unconscious on the couch at the time. I’ll be there next week though. 🙂

On the plus side, I received my cell phone gear from Cingular, including a data cable (pictured to the right), which I used to modify my phone. See, the LG CU500 I have now is a 3G phone, and thus capable of good data reception. Google Maps Mobile is extremely cool, for example.

However, Cingular annoyingly broke this functionality when they released the phone. After installing any “unapproved” Java application onto the thing, it asks for approval every single time it connects to the damn network, while you’re using that application. With Google Maps, this makes it damn near unusable.

But those clever people over at howardforums.com figured out a way to bypass this. So with the cable and a piece of software called BitPim, I was able to modify the phone to stop asking me those stupid questions. Suddenly Google Maps Mobile and GMail Mobile are the greatest things ever. 🙂

St. Pats pics up soon. 🙂

Blog by phone: Not so simple

I’ve been trying to get the ability to post pictures to my blog from my phone working for the last week or so. Previously, I used Postie for this sort of thing, but since I’ve switched to GoDaddy hosting, I’ve discovered that that method just don’t work. The fault is, basically, GoDaddy’s shared hosting plan and their insane method of supporting PHP. Ugh. I will not be renewing my hosting with them. I may switch hosts and attempt to get a refund on the remainder, actually.

So I tried a few other tricks. XML-RPC works and I can post from my phone with it, however the clients I’ve put on the phone don’t support pictures too well, or the phone doesn’t support the clients too well, or some damn thing like that. I dunno yet. I tried to get a cable for my phone to let me hack it open a bit wider and allow that sort of thing to work, but finding one turns out to be difficult on short notice. Stores just don’t have them.

So I tried blogmailr. It’s a service that combines the two.. You send email to it, it converts it into an XML-RPC post to your blog. That works too, but photos don’t seem to survive the transition. I suspect this is a problem with blogmailr.

All in all, it looks like I’ll be unable to post photos of my trip this next week on a “live” basis. So just look forward to a gallery of images when I return instead. I’ll have to sort out the live posting capabilities that I used to have sometime later.

Enable Firefox spell checking in WordPress 2.1

Important note: This plugin only applies to WordPress 2.1 – 2.1.2. The fix is included in the 2.1.3 source by default, and this plugin will no longer be needed.

Edit: Yes, I’ve just looked at 2.1.3 (which was just released) and this fix is in there. Do not use this plugin with 2.1.3 and up.

Lots of people like the new WordPress 2.1, but I noticed several complaints over on the WordPress support forums about the fact that the Firefox inline spell checking seems to not be working with the new editor.

I investigated, and it turns out to simply be one of the default settings of the version of TinyMCE that is being used. Even though it has a spell check button, some people prefer Firefox’s automatic spell checking. I can understand that, I use it all the time myself.

Fortunately, WordPress includes hooks for changing those TinyMCE settings, so it was a matter of a few minutes to create a plugin to deal with the issue.

Here’s a plugin to do just that. It’s simple to use, just upload to the plugins directory, then activate it in the Plugin panel. No configuration needed, it just turns the Firefox automatic spell checker back on in TinyMCE. Simple.

Download FFSpell

Enjoy!

Picasa Web WordPress Widget

THIS PLUGIN DOES NOT WORK ANYMORE. I doubt I’ll be updating it any time soon.

Playing around with my new Picasa Web access, I found the RSS feeds quite nice. So I made a widget for them.

Picasa Web Widget

Basically it puts a slideshow of photo thumbnails from one or more Picasa Web RSS feeds into your sidebar. You can click them to go to the photo’s page on Picasa Web. Uses divs and names and all that good CSS stuff to make styling them easy, if you want.

Enjoy!

—-

Update: Version 1.1 actually works now. )

—-

Update: Version 1.2 now has four additional options. Now you can:
-Turn javascript image rotation on/off.
-Limit how many images will be rotated through.
-Display more than just the one image.
-Control whether or not the images are shown in a random order.

The image rotation script has also been corrected to work in both IE and Firefox (and probably others as well).

—-

Update: Version 1.3 adds Brian’s fix for filenames with unusual characters in them being in your web album.

—-

Update: Version 1.4
– Output will now validate as valid XHTML. Should work all the time. Important note: Use the class for CSS styling of anything, the ID is only there when you are only showing one image.
– Added the ability to display descriptions below the thumbnail. It even works with rotating images. )
– Fixed the case where you are showing multiple images in a non-random order.

—-

Update: Version 1.5 – Corrected a problem where it would only show the last feed when you give it multiple feeds.

—-

Update: Version 1.6 – Corrected some cases where the rotate images javascript would fail to work in certain scenarios.

DNF = No Rush…

Just saw this headline over on slashdot and got the shock of my life:
3D Realms Won’t Rush Duke Nukem Forever

No kidding? After 10 years of development, they’re not going to rush it out the door? Really? Shocking!

There’s a pretty funny discussion going on over there about this shocking, shocking news.

My favorite comment so far:
“…Duke Nukem Forever has taken more time to create than NASA took to design & build a pair of robots, fly them to Mars, and drive them around for a year.” (note, it’s actually 2.5 years)

Addition: A good page with info on the things that have happened while DNF has been in development: http://duke.a-13.net/

Fun with PHP and WordPress

Guy over here asked how to display hockey scores on his blog. Here?s my solution?

Edit: Fixed a minor problem with the regular expression. Some of the soccer team names caused problems on that feed.

A quick googling tells me that exactscores.com seems to have feeds for scores for lots of stuff, however they also put horrible amounts of advertising into the RSS feed. Nevertheless, that can be worked around, if you want. )

The actual score information in the feeds comes in the titles, and it looks like this:

(No)001/1 (BST+2h,Start at)03:00 (Home Team)EDM OILERS (Final)3-6 (Away Team)ANA MIGHTY DUCKS (Status)Finished (First Period)0-3 (Second Period)3-2 (Third Period)0-1 (Full Time)3-6 (Over Time)- (Penalties)- (Scorers)LUPUL(19)

Now, that is pretty ugly. But, at least it?s in a semi normalized format: (Key)Value? The Scorers at the end isn?t pretty, but we can deal with that later. Also, thankfully, the actual scores in all the ones I checked always start with (No), so we can use that to determine which bits of the feed are actual scores and which are not.

So here?s a simple script to retrieve a feed and then display only those bits that start with (No):

< ?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.exactscores.com/HockeyLivescoreRss.xml');
echo '
    '; foreach ($rss->items as $item ) { if (preg_match('/^(No).*/i',$item['title'])) echo '
  • '.$item['title'].'
  • '; } echo ''; ?>

Obviously, the output of this is ugly, but it proves that we?re only getting scores out of the feed.

So, now we need to parse that string and get more useful data out of it. Here?s where preg_split and some rather disturbing regular expression syntax is your friend?

$uglyscores = preg_split('/^(([^)]*))[^s]|s(([^)]*))[^s]/',
	$item['title'], -1, PREG_SPLIT_DELIM_CAPTURE);

I called it $uglyscores for a reason. This returns an array with the bits of the scores nicely parsed out, but because of the regular expression I used, there?s a blank string between each pair of data, so let?s reformat this mess into something nicer:

$i=1; // skip the first element
$scores = array();
while ($i<count ) {
	$scores[$uglyscores[$i]]=$uglyscores[$i+1];
	$i+=3; // skip the blank separator
}

This gives us a nice array of elements that we can then reference by the key names. So we can use stuff like $scores[?Final?] and such.

So now that we don?t have to display everything, let?s put it all together. Here?s a combination of all of the above that outputs the two teams and the final score only:

< ?php
require_once(ABSPATH . WPINC . '/rss-functions.php');
$rss = fetch_rss('http://www.exactscores.com/HockeyLivescoreRss.xml');
echo '
    '; foreach ($rss->items as $item ) { if (preg_match('/^(No).*/i',$item['title'])) { echo '
  • '; $uglyscores = preg_split('/^(([^)]*))[^s]|s(([^)]*))[^s]/', $item['title'],-1,PREG_SPLIT_DELIM_CAPTURE); $i=1; // skip the first element $scores = array(); while ($i<count ) { $scores[$uglyscores[$i]]=$uglyscores[$i+1]; $i+=3; // skip the blank separator } echo "Home Team: ".$scores["Home Team"].""; echo "Away Team: ".$scores["Away Team"].""; echo "Final Score: ".$scores["Final"]; echo '
  • '; } } echo ''; ?>

And there you have it. If you want to display different information, just modify the stuff in those echo lines towards the end.

The key is finding the RSS feed with the data you?re interested in. Once you have that, it?s usually fairly straightforward to parse it and redisplay it nicely. )

Happy Towel Day!

A towel is about the most massively useful thing an interstellar hitch hiker can have. Partly it has great practical value – you can wrap it around you for warmth as you bound across the cold moons of Jaglan Beta; you can lie on it on the brilliant marble-sanded beaches of Santraginus V, inhaling the heady sea vapours; you can sleep under it beneath the stars which shine so redly on the desert world of Kakrafoon; use it to sail a mini raft down the slow heavy river Moth; wet it for use in hand-to-hand-combat; wrap it round your head to ward off noxious fumes or to avoid the gaze of the Ravenous Bugblatter Beast of Traal (a mindboggingly stupid animal, it assumes that if you can’t see it, it can’t see you – daft as a bush, but very ravenous); you can wave your towel in emergencies as a distress signal, and of course dry yourself off with it if it still seems to be clean enough.

More importantly, a towel has immense psychological value. For some reason, if a strag (strag: non-hitch hiker) discovers that a hitch hiker has his towel with him, he will automatically assume that he is also in possession of a toothbrush, face flannel, soap, tin of biscuits, flask, compass, map, ball of string, gnat spray, wet weather gear, space suit etc., etc. Furthermore, the strag will then happily lend the hitch hiker any of these or a dozen other items that the hitch hiker might accidentally have “lost”. What the strag will think is that any man who can hitch the length and breadth of the galaxy, rough it, slum it, struggle against terrible odds, win through, and still knows where his towel is is clearly a man to be reckoned with.

A tribute to Douglas Adams (1952-2001)

css.php