Archive for the ‘Blog Hacks’ Category

Test of My Hacks to WordTwit A Plugin: This title is really long for that reason.

Friday, August 10th, 2007

To attract Technorati and Twitter traffic, I’m now getting all my posts logged at Twitter, and manually pinging Technorati. But I was thinking: If I’m going to ping Technoratiy, wouldn’t it be great if I could get some of my tag words into the Twitter log?

Of course it would!

So, I decided to modify the string I send using WordTwit: This involves adding code to WordTwit. But what should I send to Twitter?

Examining twitter, I noticed I get to enter 140 characters. I also noticed the url gets changed into a tinyurl that takes up to 28 characters– which I will round up “just in case”. I’m guessing (only guessing) that to get tags to show, I need to keep the title, tags and any extra characters to less than 110 characters. (That leaves room for the 30 character tiny url.)

So, I did a bit of coding to chop long titles down to 40 characters and slap on some categories at the end of the the message . I only add categories if they fit inside the 110 character budget.

The only way to test this is to post, so I’m doing that. We’ll see if this shows at Twitter! Here’s sort of what my Twit should look like if it works:

$shortTitle=trim( substr( the_title('','',false), 0, 40) );
$titleLength=strlen ( $shortTitle );
$tagLength=100-$titleLength; // twitter permits 140. The tiny url uses up to 30, other text uses about 10

foreach((get_the_category()) as $cat) {
$shortCats .= $cat->cat_name . ‘ ‘;
//echo(’
short cats= ‘.$shortCats);
}

$shortCats=trim( substr($shortCats, 0, $tagLength) );
$i = ‘\” . $shortTitle . ‘\’ – ‘ . get_permalink().’ ‘.$shortCats;

echo(’
‘.$i);
?>

This may or may not work. If it doesn’t, you’ll see a another test (with the tags listed before the url!)

Wish me luck! :)

ALinks NOT a memory Hog– usually!

Wednesday, August 8th, 2007

ALinks has been cleared! Sort of. (And, at least I think it’s cleared!)

The difficulty was mostly due to a bug in PHP 5.2.2. The bug causes Wordpress’s xmlrpc.php file to break down. For some reason I don’t quite understand, aLinks uses the xmlrpc.php. (Why aLinks uses this is a mystery. )

The fix was easy. I added this line to the top of xmlrpc.php in my blog directory.

$HTTP_RAW_POST_DATA = file_get_contents("php://input");

By “top”, I mean I placed it immediately after the <?php. ( If you cut and paste from a blog, retype the double quotes. These are sometimes replaced with slightly different quotes which will not work. Just retype.)

I found both the solution and a description of the problem at hughesfamily.net.au and red-sweater.com.

Does this problem affect more than aLinks?

Yes. The ‘xmlrpc.php’ file contains some functions associated with pinging. So, if you are noticing difficulties receiving pings (which I was) you may be having problems with this file. (Presumably, my problems will be cured now.)

Do I have to fiddle with my xmlrpc.php file to fix the bug?

No. WP 2.2.2 includes the work around for the PHP 5.2.2 bug. When you upgrade, things will be fixed.

Thanks Lord Matt for noticing that aLinks was getting all bogged up trying to ping and ping and ping and…. Now I think I have the problem licked.

Is Your Blog a CPU Hog?

Thursday, July 19th, 2007

Poor Tricia; her host told her her blogs are using too many server resources. The problem is what with running a lot of popular blogs and installing load of plugins, her blog just chows down CPU!

Tricia sent out an ABP about this at the PPP forums, so I went and visited Tricia’s Musings. After loading the page, I used the “view source” button on my browser, scrolled to the bottom and found the last few lines in the html. I read this:

</body>
</html></center>
<!-- Dynamic Page Served (once) in 3.866 seconds -->

3.886 seconds? That’s a lot. I just checked BigBucksBlogger; it took 0.73 seconds to serve the page without Cacheing. It took 1.07s with Caching. (More on caching later.)

Tricia is using WP-Cache, but almost 4 seconds is a major amount of time to serve one page. (Mind you, this number isn’t exactly the cpu. But it is proportional to cpu, so big numbers are bad.)

Anyway, Tricia is using lots of resources; it’s probably due to one very badly written plugin. Which? I have no idea.

Now I bet, you are asking me exactly what Tricia and Anabella asked: How can you tell how much time a page uses? And how can you tell if a plugin is a hog?

How to Tell How Much Time it Takes to Serve a Page

On Wordpress blogs, you can print out the amount of time it takes to serve a full page by adding this to your after your footer is loaded.

<?php printf(__(’%s seconds’), timer_stop(0, 2)); ?>

Where ever you place this bit of code, it will print the time lapsed since you first requested the page. By putting it in the footer, you can see the full time required. (more…)