Archive for Home-grown

Backup script for RimuHosting

A handy little one - a backup script for RimuHosting that will backup your Rails app and copy it to the provided backup storage account. To use it you first have to add Geoffrey Grosenbach’s backup.rake script to your lib/tasks directory, then sign up for RimuHosting’s backup service, then just save out this script as e.g. “backup.sh” and add it to your crontab. Easy when you know how.

export TIMESTAMP=`date +'%Y%m%d%H%M'`
rm -f backup.zip
rake db:backup RAILS_ENV=production
zip -r -9 -q backup.zip *
lftp -u 'myaccount,mypassword' backupspace.rimuhosting.com -e "set ftp:ssl-protect-data true; put backup.zip -o backup_$TIMESTAMP.zip; exit"

Comments

Catfish fun with script.aculo.us

Script.aculo.us is a wonderful library of Javascript functions for doing lots of buzzword-friendly snazzy effects. A recent schmancy JS trick is the catfish - a small, unintrusive advertisement that pops up at the bottom of the web page and can be closed without affecting the web page. Looking around I didn’t see any existing code to do catfish effects with Script.aculo.us so I decided I’d have to fill the gap.

Read the rest of this entry »

Comments

Image block rotation using Script.aculo.us

Here’s a handle little Javascript function that’ll let you rotate a set of DIVs as needed, e.g. to rotate a series of images for a slideshow. It uses Script.aculo.us to do a very simple looking yet quite appealing slide in/out. You’ll need to load the prototype.js file and Script.aculo.us’ effects.js file before running the code. One thing to note is that you can use any object to do this - DIVs, IMGs, etc, just assign the IDs accordingly, which is useful if you need to rotate entire code blocks and not just individual images. Enjoy!

// Shuffle a series of divs using Script.aculo.us
// Set it up like this:
// var shuffle_list = ['div1', 'div2', 'div3']; // an array of DIV IDs to rotate
// var shuffle_time = 8000; // 8 seconds
// var shuffle_effect = ‘blind’; // the effect to us: ‘appear’, ‘blind’ or ’slide’
// setTimeout(’imageShuffle();’, shuffle_time);

function imageShuffle() {
if(arguments.length == 1)
var i = arguments[0];
else
var i = 0;
var next = i + 1;
if(next >= shuffle_list.length)
next = 0;
new Effect.toggle(shuffle_list[i], shuffle_effect, {queue: ‘end’});
new Effect.toggle(shuffle_list[next], shuffle_effect, {queue: ‘end’});
i++;
if(i >= shuffle_list.length)
i = 0;
setTimeout(’imageShuffle(’+i+’);’, shuffle_time);
}

Comments

Wordpress Widgets - Enhanced Search Box

After installing Wordpress 2.0 and discovering the wonderful Widgets plugin I added a few widgets to this site. While the widgets are great and give a really wonderful level of configuration over the site, I was quite disappointed to discover that the default search box looked pretty, well, aweful:

The old search box

So I did what every self-respecting geek does, I fixed it :-) I present to you, WPWidgets_EnhancedSearchBox v0.1:

The new search box

You can download a small zip file I made of both the new widgets.php file and a diff file off the SVN source code (in case you’re into that kinda thing), along with a quick readme.txt file explaing how to install it, which you can download at will:

Comments