The care and feeding of software engineers (or, why engineers are grumpy) | NCZOnline
#nowreading
Posted from WordPress for Android
#nowreading
Posted from WordPress for Android
i was reading this article – http://mjg59.dreamwidth.org/12368.html
I captured some xmpp stanzas using my xmpp bot –
got <presence from=”purigol@gmail.com/gmail.D63F1C6C” to=”firewalrus@gmail.com/0A882B52” id=”4″>
<priority>24</priority>
<caps:c node=”http://mail.google.com/xmpp/client/caps” ver=”1.1″ ext=”pmuc-v1 sms-v1 video-v1 voice-v1″ xmlns:caps=”http://jabber.org/protocol/caps“/>
<status>Meeeep</status>
<x xmlns=”vcard-temp:x:update”>
<photo/>
</x>
</presence>
DEBUG: dispatcher ok Got jabber:client/presence stanza
DEBUG: dispatcher ok Dispatching presence stanza with type-> props->[u’jabber:client’, u’http://jabber.org/protocol/caps‘, u’vcard-temp:x:update’] id->4
DEBUG: roster ok Setting roster item purigol@gmail.com for resource gmail.D63F1C6C…
I have got some screenshots, but i will save them for later stages.
I am not sure if Google is just testing Google Voice promo in India..i believe its launch in india will radically change the voice and mobile market..
Dear google, please free us from the tyranny of mobile companies… 😉 😛
Django-OS – Live CD running on hardened kernel and LAMP stack – http://sourceforge.net/projects/djangolive/ #opensource #python #LAMP #india
via Django Live | Download Django Live software for free at SourceForge.net.
If you need to find me….get over here – http://moiblogging.wordpress.com or just leave a comment, I’ll get back to you. 🙂
import codecs
import MySQLdbconn = MySQLdb.connect(host=’localhost’,use_unicode = True, charset = “utf8″, user=’harshad’,passwd=”,db=’statusnet’)cursor=conn.cursor()
p=cursor.execute(“””select content from notice where profile_id = 1″””)
g=cursor.fetchall()
q=[]
for i in g:
j=str(i)
q.append(codecs.encode(j))print len(q)
for e in q:
print codecs.encode(e)The output of the program was as follows.
python statusnet.py
5
(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)
(u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)
(u’Hallo.’,)
(u’Wussup??’,)
(u’!harshad hi..’,)
[“(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)”, “(u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)”, “(u’Hallo.’,)”, “(u’Wussup??’,)”, “(u’!harshad hi..’,)”]
root@indiaforce:~# python statusnet.py
5
(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)
(u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)
(u’Hallo.’,)
(u’Wussup??’,)
(u’!harshad hi..’,)
[“(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)”, “(u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)”, “(u’Hallo.’,)”, “(u’Wussup??’,)”, “(u’!harshad hi..’,)”]Wow..look at the output. I got a nice tuple. Now do I send a tuple as sms??
After some time I realized that there must be a way to convert all tuples to a string and then send the strings either to the screen or to the mobile or anywhere…
Here is the code..
import MySQLdb
import codecsconn = MySQLdb.connect(host=’localhost’,use_unicode = True, charset = “utf8″, user=’harshad’,passwd=”,db=’statusnet’)cursor=conn.cursor()
p=cursor.execute(“””select content from notice where profile_id = 1″””)
y=[]
while (1):
a=cursor.fetchone()
if a == None:break
print a
y.append(a)print y
g=[]
for i in y:
s=i
b=[j.encode(“utf-8”) for j in s]for i in b:
print b
g.append(i)print “g > “,g
Output
python statue.py
(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)
[(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,)]
(u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)
[(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,), (u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,)]
(u’Hallo.’,)
[(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,), (u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,), (u’Hallo.’,)]
(u’Wussup??’,)
[(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,), (u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,), (u’Hallo.’,), (u’Wussup??’,)]
(u’!harshad hi..’,)
[(u’Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1′,), (u’hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2′,), (u’Hallo.’,), (u’Wussup??’,), (u’!harshad hi..’,)]
[‘Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1’%5D
[‘hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2’%5D
[‘Hallo.’]
[‘Wussup??’]
[‘!harshad hi..’]
g > [‘Traces, many faces, lost till the end of time… http://localhost/statusnet-0.8.2/index.php/attachment/1’, ‘hello.c http://localhost/statusnet-0.8.2/index.php/attachment/2’, ‘Hallo.’, ‘Wussup??’, ‘!harshad hi..’]I dont know how many times we land up in a similar situation, now that we have got a list, we can easily iterate through it and get a sleek string as output. No hassles at all.. It still shows some hiccups, nevertheless it works..kludgy but effective. Can work for any amout of rows that we need..
Main intention of writing this place is that I couldent find a better example on google and wondered if I write it, might be useful, and if someone is finding a solution for it, here is it.. 🙂
End of Logs.
Posted via email from [root@localhost /root]#
PS – In case you wonder I havent added any exception handling code..it is one of my prime mottoes not to write code generating exceptions. so far its been good. 😉
print q
Python! Yea!
India Force Linux
6 years ago, I had my first ever tryst with Linux. One step towards the goal. Coming here was a task I dont want to remember. Still, I will reach to the top.
Here comes Agneya. The first release from India Force Linux.
Google completes its 10 years, 28 September 1998 – 28 September 2008..
Starting from what was called as ‘Dont be Evil’, Google today is the world’s largest database holding tonnes of secrets about people, their habbits, their thinking, their culture et al..
In the first 10 years, Google has introduced several user oriented web softwares that helped them remorph the IT industry..Initially, Google began its life as a simple web search engine no one could had imagined to be what is perheps an integral part of their computing experience. There are other players in this market, like MSN, Ask, the recent Cuil, but Google has outcasted them and I dont think there would be anything much left for anyone to try as far as Web search is concerned.
Long live Google, and dont forget, the privacy bomb’s ticking.. 😉
A kludge (or, alternatively, kluge) is a clumsy or inelegant solution to a problem or difficulty. In engineering, a kludge is a workaround, typically using unrelated parts cobbled together. Especially in computer programs, a kludge is often used to fix an unanticipated problem in an earlier kludge; this is essentially a kind of cruft.
I was searching data on my old disk and I found some interesting code I had written(rather abandoned) an year and half ago. At that time, I was very fascinated by the concept of Google News, which scanned and gathered news from almost 450 sources and mash up them together on one single page. Mnay sources, one destination. Needless to say, Google created a smash hit product.Life appeared easy, all of sudden.
Given my nature, it wasent surprising that I desired to write the next Google News Killer app. It began at night…around 10:30 to be precise. I was determined to finish the program in a nights time. Python was my original (and only) choice that seemed suitable for me to create the next biig thing. Googling around I found that a module feedparser.py makes parsing RSS feeds easy(so to say). However, there was a problem – At that time, I had no clue of what XML meant. That was only the beginning. Later, I also discovered that I had extremely limited knowledge of HTML..Then I realized that my Python basics were giving me plenty of surprises…
Bah..it looked so bad, here I was trying to write a good program, and there were tonnes of difficulties in first path itself. However, determination took over desperation, and after tweaking and pondering for well over 46 minutes, I was able to produce an extremely kludgy , extremely basic, extremely primitive Google News Killer – Wow…..the feeling was so good. Imagine – writing something out of scratch, and that too without any help(ok, I took help from Mark Pilgrims feedparser.py and python.org) I chose to call it News Crawler.
Get the python file by clicking the link – check-news Dont forget to rename it the file to check-news.py and also, make sure that identions are proper.
Now something about the code.
1. As I said earlier – the code is extremely dumb, extremely kludgy, extremely primitive, extremly basic and theres lot of shoddiness in there. Dont laugh at it even if it appears funny.
2. The code has heard nothing of security, and is meant to run under controlled environment.
3. It dosent make use of any SQL database backend, but is wise enough to store the RSS feeds on HDD before dissecting them,and extracting useful content.
4. It expects that the XML files are in Unicode format. Some rouge sites make use of shabby encoding, which raises an exception in the program.
5. I havent added any exception handling, just laziness, nothing more.
6. For reference, I have shown how we can incorporate Slashdot and Reddit feeds on single page. You can add in your favourite feed.
ToDo
1. Make use of a good HTML templeting system.
2. Solve the problem of unicode.
3. Add error checking and improve its utility by making use of Pythons object oriented features.
4. Add a SQL backend system for storing the parsed RSS data. To be honest, its the toughest job to do.
5. Post up a nice powerpoint presentation describing the system. 🙂
5. PS – I will definately not do anything of above unless someone seriously decides to fund me.
After a long time I am back to programming world, I got so busy with other things that I had to abandon my dream project, but who knows, someday it may come true.. 😉
hi, I was trying to perform a similar act when I bumped into ur blog. Unfortunately I am nbot able to download your .py script. Can you please email it to me
san.grad@gmail.com is the Id.
Thaks in Advance.
Hey
cann you send me the source pls .
Reply