## New WordPress hotness

Since I finally went ahead and upgraded the site to the latest version of WordPress, I finally made a few tweaks to my ugly-but-functional theme to take advantage of some relatively new features. In particular, the sidebar over to the right is being managed as a series of widgets, instead of all being hard-coded into the theme. Doing that also gave me the opportunity to put up a tag cloud, which I believe all the cool kids started doing a couple years ago. Note that only posts I’ve made since upgrading to 2.3 have been tagged (since that’s when WordPress added native support for tags), so don’t think the cloud is going to give you an extensive archive.

And since I was mucking about in the theme, I also added some CSS that plays nicely with Vim‘s `:TOhtml` command (with `let html_use_css = 1` somewhere in your `.vimrc`). The result gives me an easy way to syntax highlight the code I post, like this:

`#include <stdio.h>`

#include <stdlib.h>

static unsigned long long

fibonacci (unsigned int which)

{

unsigned int i;

unsigned long long a = 0;

unsigned long long b = 1;

if (which < 2)

return which;

for (i = 2; i <= which; i++)

{

unsigned long long tmp = a + b;

a = b;

b = tmp;

}

return b;

}

int

main (int argc, char *argv[])

{

if (argc >= 2)

{

int which = atoi(argv[1]);

if (which >= 0)

printf("Fibonacci number #%u is: %llu\n", which, fibonacci(which));

else

{

fprintf(stderr, "Must give an nonnegative integer\n");

return EXIT_FAILURE;

}

}

else

{

fprintf(stderr, "usage: %s number\n", argv[0]);

return EXIT_FAILURE;

}

return EXIT_SUCCESS;

}

Yeah, hardly the most exciting code for a demo, but easy syntax highlighting will come in handy later.

As with most upgrades, if something broke, let me know.

## 3 Responses

Hmm, if you look at the post in the RSS feed, the colors don’t show up, since the CSS doesn’t get pulled in from there. Oh well.

As usual, explain?

How the Fibonacci function works? The invariant for the

`for`

loop is that, after each iteration,`b`

is set to the`i`

th Fibonacci number, and`a`

is set to the (`i`

-1)th Fibonacci number.The more obvious recursive definition is bad because you end up repeating a lot of work. For example,

`fibonacci(10)`

would need to compute`fibonacci(8)`

and`fibonacci(9)`

, but`fibonacci(9)`

ends up calling`fibonacci(8)`

as well. You end up running in O(φ^{n}) because of all the repeated work, instead of O(n) like the iterative implementation, which only computes each intermediate Fibonacci number once.