Mostly about my amusement

Month: October 2007 (page 2 of 2)

Fun with WordPress tags

Going from UTW to WordPress 2.3’s built in tag system was mostly painless. But there are somethings I miss about UTW. Two of those things are being able to display “Tags: None” and having my tags show up in my RSS feeds. Here is how I was able to put both back into my blog.

Adding “Tags: None” to my theme

I’m not a PHP programmer. I had thought I could just do $my_tags=the_tags(); and put in an if..then loop to check if it’s empty. That did not work; referencing the_tags() would cause the output to go to the $content and get displayed.

PHP has a function called ob_start(). From the manual page:

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

That’s good! Looking around some more I saw that using ob_get_clean() can put that buffer into my variable. That’s what I wanted so I could just capture and test the output. Here is the code I put into my theme template.

<?php if (function_exists(‘the_tags’)) {
ob_start();
the_tags();
$my_tags = ob_get_clean();
if ( $my_tags != “” ) {
echo $my_tags;
} else {
echo “Tags: None”;
}
} ?>

This lets me check the output from the tags and if it is empty then I can display “Tags: None” when I want.

Update: There is an easier way without using ob_start(), using get_the_tags().

<?php if (function_exists(‘the_tags’)) {
$my_tags = get_the_tags();
if ( $my_tags != “” ) {
the_tags();
} else {
echo “Tags: None”;
}
} ?>

I thought about this because a) it’s easier, and b) I think that wp-cache might do this and then my theme might cause issues.

Adding tags to my feeds

Making feed include tags was a simple matter as well. I had read on Angsuman’s blog about a plugin that lets you append copyright notices to your feeds. I downloaded it and took a look at the plugin. Simplest code in the world, I just modified Angsuman’s plugin. Here is what it looks like.

<?php
/*
Plugin Name: Add Tags to Feeds
Plugin URI:
Description: This adds WP 2.3 tags to your feeds.
Author: Jan Dembowski
Author URI:
Version: 1.0
*/

function addTagsToFeed($content) {
global $my_tags;
ob_start();
the_tags();
$my_tags = ob_get_clean();
if(is_feed()) {
return $content.”<p class=”tags”>”.$my_tags.”</p>”;
} else {
return $content;
}
}
add_filter(‘the_content’, ‘addTagsToFeed’);
?>

Nothing to it. My feed validates and now the tags are in the feeds too. Seeing how existing code uses add_filter is probably the best way to learn by example.

Ubuntu on a USB stick with XPS 720

Fixing the MBR on Vista 64 bit or how to remove GRUB from Vista. Keep this link handy, it saved me a lot of time.

Well running Ubuntu 7.10 beta did not work as well as I planned.

The 2 GB USB memory stick I had laying around was too small. This caused the installer to just stop and die around 70% or so. I printed out the coupons of the day and took them with me to BestBuy. I purchased a PNY 8 GB OPTIMA Pro Attache USB stick. It’s as no-frills as you can get and does not come with any software.

This time the installer ran, copied all the files, etc. It also installed GRUB into the MBR of my first hard drive.

Remember I thought that Vista would not play well with other operating systems? Oh, yeah that. My system could not boot off of the hard disk anymore.

This is how you can uninstall GRUB from a Vista partition:

I went to http://www.cpuguard.net/nedlasting/mbrfix.htm and read the whole page. I then downloaded and extracted MBRFIX.ZIP onto another USB stick. This stick was FAT32 formated and I put the contents into the directory called SAVED.

I booted off of my Vista 64 install DVD, ran the command prompt located the directory on that USB stick and ran

MbrFix64.exe /drive 0 fixmbr /vista

And all was right in the world. XP comes with FIXMBR but I could not find Microsoft’s equivalent for Vista 64.

After I booted up Vista a few times, I went back to the Ubuntu install CD. I mounted the 8 GB USB memory stick (it mounted it on /media/disk from /dev/sdc1) and ran

grub-install –recheck –root-directory=/media/disk –no-floppy /dev/sdc

On my system this put the root as (hd2,0) which just plain won’t work. While I was still on the live system I ran from a terminal window

sudo vi /media/disk/boot/grub/menu.lst

and located the entries I needed. All (hd2,0) had to be switched to (hd0,0) because in my BIOS when I select “Boot from USB device” that USB device gets treated like the first hard disk. I also removed the Vista section just because it makes sense.

I’m running that installation right now and doing a software update. On the 8 GB stick I have 4.4 GB free. Once I have it up to date the fun can really begin. Wonder if Compiz will like my setup?

Installing Ubuntu on a Dell XPS 720

Update 6/3/2009: Follow the instructions here at PenDriveLinux.com for Ubuntu 9.04, it works with the Dell XPS 720 very well. The only odd thing is that I have to re-enable the NVidia drivers between reboots. When you do enable it, don’t reboot. Just log out and let the auto login go and you can use the full Compiz effects.

Ubuntu 7.10 beta being installed

I run Vista 64 bit on my XPS 700 720. Looking at how it boots up, I am not sure that Microsoft will work with another operating system. And I do use this computer for work-ish *cough* games *cough* reasons.

I’ve just downloaded the 64 bit iso image for Ubuntu 7.10 beta and burnt it to CD. I’m installing the software but not on my hard drives, I’m installing it onto a 2 GB USB memory stick I have lying around.

This should let me install what I want to play with without me having to take the plunge exactly on this computer. I just have to remember to hit F12 when I boot up so the BIOS presents me with a boot menu.

As the install image booted up it played with my monitor settings and set it for 1680×1050. That’s not bad; last time it insisted on 1024×768. The sound card was not installed for the live session but that’s probably fine for now.

It’s installing right now as I enter this; I’m using Firefox in the live session. It’s going slow and I’m tailing /var/log/messages in another window to see if the drive suddenly dies.

Once I have it working off the USB drive entirely then I’ll mess with the drivers to see if I can get sound and Compiz working at 1920×1200 with full acceleration.

You need to be this tall to use a computer

Actually that should be “you need to understand how an application works before you can use it”. I think that Jammie Thomas would be better off today if she understood what could happen in the real world with using an application.

When I get Opensuse (this weekend I’ll get OpenSUSE 10.3) I’ll leave it running for a while to benefit others. Once I’ve done that long enough I’ll take it down. Contributing to the Opensuse torrent is a deliberate action on my part, it’s not automatic and does not share files on my hard drive. I’m not sure that I can use µTorrent to just share folders; never wanted to so I just don’t know.

Kazaa is a P2P file sharing app. IMHO It’s different from Bit Torrent because in Bit Torrent you need to leave the download running in order to share it. Apparently with Kazaa it’s trivial to share out your whole music library and this has gotten Kazaa into deep poo with the music industry.

This lady was sued by the RIAA and rather than settling for the extortion she went to trial. The RIAA behaves like a shake down organization and claims that if you rip the CD’s you paid for to your iPod then you are a thief. I did it with my CDs (can you get Basia on iTunes?), apparently so did the POTUS when he had the Beatles on his ipod. Soon I am sure they will insist on a pay-per-play model.

Oddly enough she lost. Her defense was basically “I don’t know how this happened, but it was not me. Maybe gremlins did it”. If she had used a different Kazaa account name than the one she uses for other services, then maybe. But her lawyer tried the dumbest defense possible by just claiming ignorance of the file sharing of those 24 music tracks.

I don’t like the RIAA. I think they should be shut down and let consumers alone instead of trying to scare them with “the sky will fall on you if you don’t contact our settlement extortion centers” tactics. I think that they are hurting their industry more than they are protecting it. But if you are caught doing something that is illegal, whether it should be illegal or not is moot, then you just might want to be able to demonstrate that it was not you instead of just saying it.