“Tweet This” for Blogger Blogs

I had migrated out of blogger in 2007. Reasons for which i’m not quite sure of. One thing that attracted me in WordPress is the availablity of plugins and the ease with which i was able to work with the php code. So when i had to do a ‘tweet this’ link for each post on my blog all i had to do was write this at the right place -

    <a href="http://twitter.com/home?status=Now reading <?php the_permalink(); ?>" target="_blank">
        <img src="http://jerrymannel.com/blog/wp-content/themes/SIM4.0/images/s-to-twit.jpg"
        style="border:none;">
    </a>

So yesterday, i was lazing around in the evening after a visit to the local library, one of my friends called. She was a smart-enough-techie for a business student. The only chick i knew who owned a Mac (i was so ready to dump all my girl-friends for her, coz she had a Mac. But her boy-friend owns an Audi so she ruled me out. 150cc Pulsar DTSi doest really stand a chance against an Audi). She had she blog up on blogger. Her problem how to get a ‘Tweet This’ link for each and every post on her blog.

I just dropped everything i was doing (nothing much infact) and got down to crack the problem. And this is how its done.

First get the full code for the .blogspot.com site that you have by navigating to Layout -> Edit HTML page. Check the “Expand Widget Templates” and copy the content of text area and back it up.

Next check the code that you have in had and make sure that its not the Classic Theme code. Just scroll and see you dont come across anything like <$BlogItemXXXXXXXXX$> in it.

Just like WordPress, blogger also loops and adds the blog entry(the simplest logic). So find a tag like <b:includable id=’post’ var=’post’>. This is the start of the section that will genrate the post-title, post-content, date-of-publishing, labels, etc. and similar miscellaneous information.

Now to add a “Tweet This” link to the each post use this code -

    <a expr:href='&quot;http://twitter.com/home?status=Now Reading -&quot; +
    data:post.title + &quot; &quot; + data:post.url' target="_new">
        Tweet This
    </a>

Depending up on where you are going to add that piece of code, you might have to add the necessary tags and define the properties. For eg. if you want the “Tweet this” link to be like the way its there at – http://jerryreghunadh.blogspot.com/ – this is the code that you need to add at the footer section :

    <div class='post-footer-line post-footer-line-2'>
        <span class='post-labels'>
            <a expr:href='&quot;http://twitter.com/home?status=Now Reading -&quot; +
            data:post.title + &quot; &quot; + data:post.url' target="_new">
                Tweet This
            </a>
        </span>
    </div>

Thats it. I guess this fixes the problem for you too icon smile Tweet This for Blogger Blogs

 Tweet This for Blogger Blogs

EeePc Initial Reactions

Last Friday i bought an EeePc for my brother. I have heard a lot about this little master, or rather monster, but i had to see it for myself, what it could really do?logo EeePc Initial Reactions

Got it home and the first thing i do, hook it on to the wifi – a plus over there. Then it was time for some serious browsing. Did that and the only thing that i found a bit difficult was typing. C’mon the entire keypad fits in my palm and how am i supposed to type. But still again a plus. One of the things that i need to do from a usability point of view, for any Linux box, is to play movies. Plugged in my thumb-drive and double clicked a movie. Cool! just played it just like that, without any problem.

So far EeePc has impressed me in more ways than most girls have ever done. But word of caution, if u r a linux junkie who likes to get your hands dirty by doing – ./configure; make; make install- then EeePc is not the one for you. Coz it has everything that you need for a, err say and over sized mobile with out the calling facility. (one of the reasons why i goes to my brother icon smile EeePc Initial Reactions )

My initial reactions with EeePc has been captured with the inbuilt cam like this -

image 00000 300x225 EeePc Initial Reactionsimage 00001 300x225 EeePc Initial Reactionsimage 00002 300x225 EeePc Initial Reactionsimage 00003 300x225 EeePc Initial Reactions

Here are somethings that i have tried out on EeePc -

  1. Locate the Terminal (this is fun, coz u really need to know linux like your backyard to locate this)
  2. Write a “Hello WorldPython program (this was written at Barcamp Bangalore 8 )

icon wink EeePc Initial Reactions

 EeePc Initial Reactions

Useful Python Snippets

My love for Python has indeed grown with the constant usage. Each day i find something that is really interesting with that. By interesting i mean, C will complain and whine if i do that, PERL say ‘lets give it a try‘ and Python is like, ‘C’mon baby, i’m ready!!!’.

My advice to good C/C++ programmers is that, stay the way you are, picking up PERL / Python will screw up you skill. C is like the wife with whom you have to be loyal, Python is like the liberal girlfriend, who lets you flirt with other girls and wouldn’t mind.

Coming back to the purpose of this post, here are some of the snippets that proved useful to me and could also help you out with in your scripts -

File to List – Move the contents of the file in to an list, line by line

list = ([line for line in open ( "names.txt", "r")])

Pattern Matching – the only thing that i miss in Python is the regexp usability that PERL gave me. Some how i feel that using regexp was a lot more easier with Perl, than with Python

# import the regex pacakge
import re
#create the regex object
pattern = re.compile("error")
# search for pattern
re.search(pattern, sampleString)

re.search return TRUE / FALSE depending on the result, so that it can be used along with if <> : clause

Detecting the OS and creating directories – this helps to solve the variation in the Windows directory navigation (..\\..\\) and the Unix style navigation (../../)

# import OS packages and time package
import os, time, sys, os.path
# create a unique directory name based on the time
dirName="Run-"+time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())
# detect the OS
if os.name == "posix":
    logPath = "../../logs/"
    resultsPath = "../../results/"
else:
    logPath = "..\\..\logs\\"
    resultsPath = "..\\..\\results\\"
# create the directories
os.mkdir(logPath+dirName)
os.mkdir(resultsPath+dirName)

String is like a List – the best part of Python

str = "Hello"
# will print H
print str[0]

Happy scripting, and i hope this will be helpful to some … icon smile Useful Python Snippets