Saturday, December 30, 2006

Blogger Tag Cloud

One good thing about the blogger beta is that it supports Labels a.k.a. Categories/Tags (at last!), so one can categorize his posts. Blogger also allows showing the list of labels from your blogs and allows user to filter posts based on the labels. The problem is that the layout of labels is not customizable or is it? Actually, with some (not so elegant) lines of javascript and css, we can make these labels display as a tag-cloud pretty much what other blog platforms support. Here's what we need to do:
Preamble: Edit 2: Edit the template to give the ul tag (which displays the labels) an Id (for e.g. labelUl), this can be done by clicking on "Expand Widget Template" checkbox and scrolling to the code in template which has a div with ID: "Label1". The UL would be contained within this. Enclose the (<data:label.count/>) within a span and save the template.

1) Firstly we'll make the list appear horizontally instead of vertically, that way we can free up some screen real-estate. So we add the respective styles for the ul and li elements within the style tag under head:
#Label1 {display:none;word-wrap:break-word;}
#labelUL {list-style:none;margin:0px;padding:0px;}
#labelUL li{padding:0px 3px 0px 0px;margin:0px;display:inline;}
Add the noscript tag to display the label div, in case user has js turned off
<noscript>
<style type='text/css'>
#Label1 {display:block;}
</style&g;
</noscript>
So at least we've got the list to display horizontally instead of vertically.
2) Now we need to change the font sizes of the labels based on their weights (i.e. the larger the number of posts tagged to a label, the bigger the text size for that).
For that we hook our DOM walk-through javascript to window.load, this is what I've done:


<script type='text/javascript'>
window.onload = function(){
var labelDiv = document.getElementById("Label1");
var ul= document.getElementById("labelUL");

try{
if(ul.childNodes.length>=0)
{
var weights = new Array();
//should be a div
var li,text, re;
var textNode;

var lis = ul.getElementsByTagName("li");
for(var i=0;i<lis.length;i++)
{
li = lis[i];
textNode = li.getElementsByTagName('span')[0];
text = textNode.innerHTML;
re = new RegExp("[^0-9]", "g");
text = text.replace(re,"");
li.title = text + " posts";
weights.push(new category(text,li));
textNode.innerHTML = "";
}
weights.sort(sortNumber);
var mean = Math.floor((parseInt(weights[0].weight)+parseInt(weights[weights.length-1].weight))/2);
//lets go
var weightFactor = 1;
for(i=0;i<weights.length;i++)
{
weightFactor = parseInt(weights[i].weight)*100/mean;
if(weightFactor<80)
weightFactor = 80 + weightFactor*.1;
else if(weightFactor>250)
weightFactor = 250;

weights[i].li.style.fontSize = weightFactor + "%";
}
weights = null;
labelDiv.style.display = "block";
};
}
catch(e){
if(labelDiv!=null)
labelDiv.style.display = "block";
}
}

function category(weightParam,e)
{
this.li = e;
this.weight = weightParam;

}

function sortNumber(a,b)
{
return a.weight - b.weight;
}
<script>


I don't let any tag to be less than 80% of normal text size, you don't want any label to be illegible due to it's size. The js is simple enough to understand and as I said it isn't the most elegant piece of code that you'd come across but hey it works for me. I tested this out on IE 7 and Fx and I'd guess it should either work or downgrade silently on other browsers, worst case the Labels section would look a little whacko but I promise it wouldn't steal your credit card information or conduct any phishing attacks :-).

Edit:Just figured out that in the template if you click on "Expand Widgets.." checkbox, you can set the Id for the ul element and even perhaps write a javascript inline without having to resort to a onload function. I am too lazy to change the code on my page though (don't fix it if it ain't broke).

Tuesday, December 26, 2006

Zuned!

As I write this, the Zune Software installation is going on in the background and it has failed on me twice! Well, not really its fault, I got disconnected from my wireless connection on both occasions while it was downloading the firmware update (by the way, the error message was not at all handy, it said close all the applications and restart the system!). I don't think doing an update check the first thing during a new install is such a great idea, when people get new stuff they want to try it out as soon as they can and making them wait while a 30 MB something update is getting downloaded is definitely not on. By the way, the Circuit City guy told me that the Zune is selling quite well in these area and at times even outselling the iPod. Anyway, more on the OOBE and the Album-art fixer app that I wrote later.

Tuesday, December 05, 2006

The 6'O Clock Alarm

I generally hate waking up in the morning to an alarm, I believe that using alarms interrupt your sleep and if you're still sleeping during the hour when you should be "supposedly" up; it means that the body and mind needs more rest, as simple as that. I am not against using alarms as a one-off thing or using it to get up cause you have things planned for the day which you love doing, but getting up early in the morning just so that you can get to work early; please no unless you are in love with your job! I've used the alarms in the past quite often but I used it more or less to get things done which I loved doing. The last time I had to resort to alarm unwillingly was when I was in school, I had to get up like 5:30 in the morning to make it to the 7:30 assembly! I just don't understand how we expect from school children, does forcing them to get up so early make them any better? This gently reminds me of a British Airways ad from past which read something like:
It's same everywhere; children go to school (in the morning),
children run back home (after school)!
Unfortunately, these days I have to resort to alarms in the morning (not by choice) but one thing's for sure; the 6'O clock alarm would never ring...or would it?

Last.fm, Pandora or Musicmatch Jukebox Radio

Thanks to the social networking, even sharing music tastes online has these days become a fad; and all of a sudden there've been quite a few services online which provide you recommendations based on your tastes, the most popular of them being Pandora and last.fm. last.fm provides recommendations based on other listeners who share the "same" music taste as you, whereas Pandora uses some "fuzzy" logic to get it's recommendations. Before either of these services were on the scene, I would use MusicMatch Jukebox radio (due to its free CD quality streaming for one hour) and generally search for a particular artist and select "Play this and similar artists", and now after trying both Pandora and last.fm the same way, at least I've found that MusicMatch's recommendations were the best. The way I tried is quite simple; search for the same set of artists (mostly 80s bands like a-ha, Duran Duran, Cyndi Lauper, Belinda Carlisle etc.) on all the three services and see which one plays the songs you like the most and helps you in discovering new music. last.fm came with quite good recommendations but mostly songs that I'd listened to before, so not such great a thing if you're looking at finding new music matching your taste (though it did come with "Pictures of You - Cure", which I bought almost immediately!); Pandora's recommendations were beyond me but MusicMatch would per session at least play one song which I'd fall in love with: be it Afterglow by INXS, Moonlight Shadow by Mike Oldfield, The Sun Ain't Gonna Shine Anymore by Walker Brothers or numerous others. My word of advice: if you're into discovering new music give all three a spin and see which one works the best for you; I'd recommend the Jukebox the most though.
Happy listening!

Saturday, December 02, 2006

Ambitious dream

I was talking with someone over the phone the other day about something that I was kind of reluctant to do, and he finally said to me: "Hey, that was always your dream", after I hung up I could understand why he was kind of annoyed/amazed but then I thought about the statement that he made; was it really my dream? It wasn't, it was an ambition. Well, how are the two things different? I define ambition as something tangible and materialistic, something which our outer self wants to achieve; whereas a dream can be anything from one night of peaceful sleep to being able to fly, and are what our inner self needs. This by no way means that dreams are something so abstract that they cannot be lived on in this material world, all the limits of the body are the limits of your own mind; let your mind go and your body will follow. Unfortunately we drown ourselves so much into our day to day chores and try to please so many people that we stop dreaming altogether. The moment we stop dreaming or stop believing in them is when we stop being in touch with ourselves, we are just reduced to a shadow of what we really are deep inside.

I would rather chase my dreams and give up my ambitions that come in the way than the other way round, this was just one of those cases; and I've no regrets about it.

Legend of a Band

There are singers who compose music that you like, and there are singers that compose songs which you admire and then there are singers that touch your heart and soul with their soulful music, The Moody Blues is one such band, a band whose music simple mesmerizes you. They have never failed me ever since I started listening to them way back in early 90s, their music always seemed to have that profound effect on me which always seemed to re-affirm my self-belief even during my most stressful times when I'd start doubting the sanity of very principles on which I have lived my life all these years. Maybe it's got to do with Justin's haunting voice or the theme of most of their songs (separation) or simply the lyrics; they take you on a journey to a completely different place, a place where you are so much more peace with yourself, where you are just being yourself every time you play one of their song. The place is not somewhere faraway (there's no such thing as far away, every place that you ever want to be at is right there inside your own self) but it's a journey inside your own self, a place where I've always felt safe and at peace with myself. I can still remember how I got hooked on to them, Sumit had borrowed a recorded cassette which had one song from The Moody Blues: I know You're Out There Somewhere; a song which you just can't stop falling in love with. I was too young to really appreciate the meaningful lyrics then (I didn't have to deal with pain of losing someone at age of 12) but still there was something about the song which affected me somewhere deep down inside, there was something about this band which made me feel as if there's beauty around us; we just have to close our eyes, take a deep breath and liberate our souls. Ever since I've listened to almost all of their numbers but somehow I always kind of associate myself with Justin's songs, there is so many things that he says through them and then there are so many things that are left unspoken that you want to immerse yourself in those songs. If you haven't listened to Moody Blues ever; you might want to run to your nearest music store and get their CDs, believe me you won't regret your decision ever.