BrT

Musings about technology and other neat stuff

BrT random header image



Intense Debate

November 16th, 2008 · 1 Comment   

I have installed the Intense Debate plugin for handling comments on this blog. Not that there are that many comments :-) , just to see how it works. I think it’s nice that it automatically synchronizes comments two ways to the regular WP comments, so that if you disable it, all the comments are still there.

Let me know if you have any comments, or if you find anything broken.

→ 1 CommentTags: ·

The Mac Developer Network Book Review: Pragmatic Version Control Using Git – My review of the book "Pragmatic Version Control Using Git" for the Mac Developer Network. (tags: git versioncontrol programming development reviews )
(0)




YouTube – "Star Wars" – an a capella tribute to John Williams – Very cool a capella video with John Williams music and lyrics from Star Wars. (tags: cool fun video youtube starwars johnwilliams )
(0)




EmacsWiki: Mac OSTweaks – Tips for using and integrating Emacs on Mac OS X. Particularly nice is the tip for integrating with the Mac OS X print dialog. (tags: emacs tips howto macosx printing )
(0)




Obama won!

November 5th, 2008 · No Comments   

I am not a political person, this is not a political blog, and I am not a U.S. citizen, but like many others, I have watched this year’s U.S. presidential election with much interest, and I am very happy that Obama has won. I just want to post something quick with some of the interesting media I have seen during yesterday and today.

[Read more →]

→ No CommentsTags: ·

Disabling Quit and rewriting keyboard shortcuts – Useful tips for disabling and modifying key shortcuts in Mac OS X. (tags: macosx hacks tips keyboard keybindings @readlater )
(0)




Diego Zamboni – ACM author profile page – My very own author profile page at the ACM portal. Nice overview of most of my publications. (tags: acm publications personal )
(0)




How to display random header images in a Wordpress theme

November 3rd, 2008 · 8 Comments   

I saw an article on wprecipes.com describing how to display a random header image in a Wordpress blog. While the code shown works, it is a bit verbose and hard to maintain, so I thought I’d show how the random image in the header of this blog is done.

Note: you may need to adjust some of this to the specifics of the theme you are using, but the base mechanism is the same.

In this technique, the assumption is that you have a directory with header images, located in images/headers under your theme directory (e.g. /your/blog/directory/wp-content/themes/yourtheme/images/headers/). The code shown below will choose an image at random from this directory. The images should already have the appropriate size/ratio to be shown in your blog.

Here’s the code, to insert instead of the existing <img> tag for your theme’s header image (most likely in header.php):

<?php
$curdir=getcwd(); chdir(get_template_directory() . "/images/headers");
$files=glob("*.{gif,png,jpg,gif}", GLOB_BRACE);
chdir($curdir);
$file=$files[array_rand($files)];
?>
<img src="<?php echo(get_bloginfo('template_url')."/images/headers/$file"); ?>" width="770" height="140" alt="<?php bloginfo('name'); ?> random header image" />

Some things you may want to change:

  • The location of your images (if not under images/headers in your theme directory)
  • The size of the header images in the img tag
  • The filter for the images in the glob statement (currently it will grab any gif, png, jpg or gif files in that directory)

I’m not an expert PHP developer, so there may be a more efficient way of getting a random file from a directory, I’d be happy to learn about it.

→ 8 CommentsTags: · · ·

Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source – A port of the Commodore BASIC interpreter, now as a script interpreter for Linux, OSX and Windows. Very cool. The memories… (tags: programming commodore c64 nostalgia scripting osx )
(0)