Image 01 Image 02

Posts Tagged ‘india’

then and now

Monday, January 14th, 2008

I have traveled across the length and breadth of India and I have not seen one person who is a beggar, who is a thief. Such wealth I have seen in this country, such high moral values, people of such caliber, that I do not think we would ever conquer this country unless we break the very backbone of this nation, which is her spiritual and cultural
heritage, and, therefore, I propose that we replace her old and ancient educational system, her culture, for if the Indians think that all that is foreign and English is good and greater than their own, they will lose their self-esteem, their native culture and they will become what we want them, a truly dominated nation

Read more here

http://www.languageinindia.com/april2003/macaulay.html

thanks to nukkad for the information and link :)

http://www.mumbai-central.com/nukkad/jan2008/msg00226.html

twitter action code

Sunday, December 2nd, 2007

i was planning to put this one last week when i released meninblue but thanks to exam i just got time now .

It was basically a bot that would give you the latest commentary of india’s cricket matches on your twitter and it was written in python and using python-twitter .

First the libraries you will need

GNU/Linux or its variants preferred, python,urllib,urllib2,python-twitter and sgmlib and also minidom for xml parsing .

Twitter provides you with a very easy api to work with .posting a message is just two lines.

Here is how i have tried to go about my task .

Choose the main page where you get the list of all ongoing matches and i chose wap version of cricinfo since its easier to parse with minimal html and also their html is a little complex to parse with so many iframes .

i use the sgmllib to parse the html ,the code snippet is below

def get_contents(url):
import urllib, sgmllib


f=urllib.urlopen("http://ci.plusmo.com/cricket/wap")
s = f.read()
print "Read"
myparser = MyParser()
myparser.parse(s)
a=myparser.get_hyperlinks()
b=myparser.get_descriptions()
wget_command = "wget -p --output-document=index.html "+url
system(wget_command);
print wget_command
f=open("$CWD/index.html") #change the $CWD to what dir u have
filer=f.read()
strnew= filer.replace(' ',' ')
strnew1=strnew.replace(' ','')
findex=strnew1.find('<div class="dat">')
findex1=strnew1.find('</div>',findex+1,UP_LIMIT)
newindex=strnew1.find('</div>',findex1+1,UP_LIMIT_1)
newindex2=strnew1.find('</div>',newindex+1,NEW_LIMIT)
finalmesg=strnew1[findex:newindex2]
s=Stripper()
s.feed(finalmesg)
score=s.gettext()
score=score.replace(’<’,”)
score=score.replace(’>’,”)
score=score.replace(’div’,”)
print score
print “SCRE OBTAINED”
check(score)

And now the parser class

class MyParser(sgmllib.SGMLParser):
def parse(self, s):
self.feed(s)
self.close()
def __init__(self, verbose=0):
sgmllib.SGMLParser.__init__(self, verbose)
self.hyperlinks = []
self.descriptions = []
self.inside_a_element = 0


def start_a(self, attributes):
for name, value in attributes:
if name == "href":
self.hyperlinks.append(value)
self.inside_a_element = 1


def end_a(self):
self.inside_a_element = 0


def handle_data(self, data):
if self.inside_a_element:
self.descriptions.append(data)


def get_hyperlinks(self):
return self.hyperlinks

def get_descriptions(self):

for i in range(len(self.descriptions)):
str=self.descriptions[i]
if str.find(”India”) != -1:
index=i

return self.descriptions

The next stage is to strip all html and get the full content which we can post :-)


class Stripper(sgmllib.SGMLParser):
def __init__(self):
self.data = []
sgmllib.SGMLParser.__init__(self)
def unknown_starttag(self, tag, attrib):
self.data.append(” “)
def unknown_endtag(self, tag):
self.data.append(” “)
def handle_data(self, data):
self.data.append(data)
def gettext(self):
text = string.join(self.data, “”)
return string.join(string.split(text))

And see if the last posted message was the same as the message you have ,if yes then abort posting and wait for a update to be done ( mostly for script when its running while no match is on or after play)


def check(score):
settings={
"username":"YOURUSERNAME",
"statusdelimeter1":"<p class=\"entry-title entry-content\">",
"statusdelimeter2":"</p>"
}



url1="http://twitter.com/"+settings["username"]
message=”"
print url1
statusdelimeter1=settings["statusdelimeter1"]
statusdelimeter2=settings["statusdelimeter2"]
try:
print “In to the message checkloop”
instream=urllib.urlopen(url1)
for line in instream:
if statusdelimeter1 in line:
message=line[
line.index(statusdelimeter1)+len(statusdelimeter1):line.index(statusdelimeter2)
]


print message
print score
if string.lower(message)==string.lower(score):


print "No change in Score ,May be break or match just got over"
else:
if len(score)>140:
print "LEN Greater than 140,so truncating"
newscore=''
newscore=score[:140]
print newscore
twitter(newscore)

else:
twitter(score)


except IOError, e:
raise "Could not connect."

And finally when you have the message to be sent ,just use a few lines of twitter library and its done !

def twitter(score):



import sys,os,string
sys.path.append('$CWD/twitter/')
sys.path.append('$CWDsimplejson/')
import twitter
api=twitter.Api(username='YOUR_USERNAME',password='YOURPASS')
try:
status=api.PostUpdate(score)
print "POST SUCCESSFULL"
except IOError,e:
raise"Could not Post"

Thats all the code is about :-)

check out 2s birthday update bot :-)

UPDATE: The feed and scores were taken from Plusmo services .

Z Plusmo2 Icon

cricket action on twitter

Saturday, November 24th, 2007

Twitter was always fun and now iam starting to do some things with it .

Inspired from Myles ,but his work was in ruby and i dont know much of it and iam lot comfortable with python .

so here is how you can get all the cricket updates of india matches right on your mobile when you are out roaming or on your gtalk while the cricket sites are banned in office .

  • Login to your twitter account at http://twitter.com
  • go to http://twitter.com/meninblue and choose the follow option
  • or if you are logged in to your gmail,gtalk then give ” Follow meninbue” command and you should be receiving my updates
  • And yes if you want to have the scores on your mob ,then dont forget to give out the phone details in the account section :-)

And i must warn you ,this script runs every 2 min so incase you dont want to be spammed ,follow only when you are comfortable with it !

http://twitter.com/meninblue

and thanks to sp2hari for helping out with html parsing and 2s for telling me about XPATH ,i figured out html parsing is lot tougher than XPATH and would definitely recommend it more than html parsers !.

And yes ,dont be surprised if some posts are truncated ,twitter allows only 140 chars and so i had to truncate the commentary else, it wont get posted !

PS:the libraries used are twitter,urllib,urllib2,sgmlib and XPATH ,source code will be up here soon,or if u want it then mail me at theyaga@gmail.com. will mail u the code

UPDATE: The feed and scores were taken from Plusmo services .

Z Plusmo2 Icon

Project Discover

Monday, November 19th, 2007

Hello All,

Little things sometimes leave impressions that urges you to do something about it .My recent talks with people who run these home for special god’s own children are urging me to contribute .
Contribution that can be sustained even if at some point i were to leave or someone who can take it full time .

I must accept as HoneyBee pointed out udavum and other popular organizations atleast have established enough funding channels so that they will never fall short of money .But there are countless little struggling homes who are trying to serve the same needy poot but lack of exposure and lack of funding channels us hampering them .This is the case with hundreds of orphanage home and i am starting to believe it is also my duty to help people i share the world with help provide others a better chance to live their life .

And i did talk to a couple of people and i tried explaining to them ,all of us are net savvy and we know what internet can do .If we cannot donate money or enough time to help those children i think we can use the internet to give the exposure that can may be bring them to people who won’t mind spending their money for helping special homes.

We call it ProjectDiscover and the below points are what we aim to do .

1. Visit any of the ailing special homes ,talk to the people there ,about its history ,number of inmates,founder ,what work they do and what are their future plans and also their current needs ( be it a building or set of benches or a roof thats yet to be built ) .

2. Profile everything with a camera ( snaps/videos) and write about them on a website ( blog ) and make them publicly available .

3.Give out enough information on the website so that anyone interested can easily find a way to donate them and also explain to them the incentives of donating money .Like in udavum ,If i were to donate a school bag to a child ,then i would be sent a photo of the child with the bag . Would be great isn’t it ?

4. Also create a place where the children can even voice out their opinion .

Ofcourse one man can’t take this up ,it will require a strong team that doesn’t mind doing it .I personally hope to start off by visitng blind school just opposite to the G.H and to the Orphanage Near Vayalur Murugan Temple and to Thiruvellarai Old age Home .

I will do that once i reach trichy and just after my sem exams ending on nov 29 .

Any company ? or suggestions atleast ?

if you are interested then do get in touch we can atleast start off in a small way and help some :-)

I understand ,its probably a little too big at this point ,but would like to know if people can join and may be we could help some ?

your thoughts and opinions ?? what do you think about its feasibility ?

Yay ! india won

Sunday, September 23rd, 2007

yes its India Vs Pakistan in a world cup final :-)

don’t know how long iam going to take in putting up a blog post !.blame it on the simcats :-(,posts are not coming any sooner .

[tags]india,cricket,t20[/tags]


FireStats icon Powered by FireStats