Posted Sat, 19 Nov 2005
I added a subtle feature to my blog this morning; my tag cloud now shuffles every hour. I did this by seeding the random number system using the current hour and shuffling the tags in my tagcloud, like so:
srand( Time::now.hour )
tags = tags.sort{ |a,b| rand() <=> rand() }
The result is that with each hour my tag cloud takes on a new form, and there will be 24 different combinations.
If you wanted to shuffle every hour and not repeat every 24 hours, you could also seed using the decimal representation of the current time rounded to the previous hour:
now = Time::now srand( ( now - (now.min * 60 + now.sec) ).to_i )
add to del.icio.us