how to write code?
pic1
[info]lawgon
the other day I was working on integrating an online payment portal with a site. The code supplied was in PHP - obviously insecure unusable crap. I worked the whole day and got nowhere - I could understand the code and workflow, after all I have done it before! But translation from PHP to python will not work. Mostly my code is seat-of-pants - I write the comments first and the code follows easily. Not this time. I am informed that one should first write documentation, then tests and then write code until all the tests are passed - at which stage stop writing the code. I wonder if anyone actually does this? I know a lot of people claim to do it. But I bet they cheat. So this time I am going to start with sketching out the thing with dia. Then write the tests, and see if the claim that the code will write itself is true.

shut up and hack - the unofficial fsck.in faq
pic1
[info]lawgon
I recently made a comment that no self respecting Indian member of the F/OSS community would be found dead in fsck.in. I was asked to explain - I have explained in the past, but for those who are too lazy to scroll through my blog, I will repeat myself.

fsck.in is run by Kishore Bhargava and Atul Chitnis who are arguably the biggest loudmouths in the Indian FOSS universe. After hijacking the highly successful linux-bangalore conferences they have been casting around for a formula to get mileage for their event. Having never contributed anything (be it code, documentation or translation) to the FOSS community they have torn a quotation from linus out of context and are projecting themselves as the saviours of the Indian FOSS community.

basically they are doing this by trying to create an elite caste among the community. L33t h4x0rs. People who own laptops. I have nothing against people who own laptops - I own one. But I see the 3 most prolific contributors to FOSS in my lab - they do not own laptops - on the salaries they are paid, they cannot even dream of owning laptops.

I write code, I translate, I contribute to documentation. I even appear on IRC and mailing lists and offer solutions (at least 50% of the time I am right). But I do not run around telling people to shut up and hack.

To me, the greatest thing about the FOSS movement is that it has blurred the distinction between enduser and developer. Every end user is also a contributor (except Bhargava and Chitnis). fsck.in works against that trend - it has created swollen headed monsters - some of whom used to be my friends. Frankly with friends like this I do not need enemies.

nuff said.

featherbed wickets
pic1
[info]lawgon
given the wicket for the match I would not be surprised if Mahela broke Lara's record.

golf in god's own country
pic1
[info]lawgon
Was in trivandrum to referee the South zone junior/subjunior match there. It was held in the Trivandrum golf club - a spot of mindblowing beauty. It was built by the Maharaja in 1851 - which makes it the oldest golf course in the world outside the british isles. The club house is a heritage building - built in the old kerala stye - even the wells on the course look like mini palaces! Two days of golf played in light drizzle. Competition was keen and the hospitality great. One thing Malayalees know about is looking after the stomach. No butter chicken here! Traditional Kerala food - and cooked real well.

But the club is in trouble - the government feels that golf is a rich man's game and wants to convert the course into a housing colony. (I forgot to mention that the club is situated in the most espensive area of the city). Golf *was* a rich man's game - but now many of the top earners in the Indian tour are ex-caddies. The two top juniors, Chikkagangappa and Rashid Khan are both caddies - their parents are course workers. And another caddy, Muniyappa was recently paired with Tiger Woods in a tournament. India has only 3 people in the top hundred of the world, but that is changing and changing fast. Even Japan, the golf super power of Asia has only 5. India has only 200 golf courses whereas the US has over 35,000. That is also changing.

In Trivandrum of the 8 local participants, 4 were caddies. This is the first time a zonal level tournament has been held in Kerala. So it was a good chance for publicising the plight of the club and course. The course had been handed over to the club by the state government in 1951 and maintained by them since then. And well maintained, no encroachments. So the sports minister was invited to be chief guest and give away the prizes. The function was a bit tense. Minister turned up. President made a speech about the history of the club, the progress of Indian golf and the huge potential of Kerala in the scheme. The IGU representative also emphasised the fact that caddies are reaping riches and India is doing well in world golf. Then the minister spoke. First surprise was that he spoke in english. (Ministers in the South rarely speak in english in front of their home crowds, although they do so when they are out of the state or abroad). I suppose since the parents and players were mainly from outside the state he realised this and wanted to be understood. Anyway he thanked the club for inviting him, congratulated the players and wished for more success at state, zonal, country and international events. He frankly stated that there is a dispute between the government and the club - unlike most ministers he did not make any false promises. But I have a feeling that a seed of doubt has been planted in his mind, as he *did* say that he wishes that the trivandrum leg of the south zone junior tour would grow bigger in future. Let us see.

oops, and I forgot, this is the only golf course in the world with women caddies wearing sarees.




sane i18n
pic1
[info]lawgon
One thing programmers should learn is how to format strings for translation. The word order in different languages is different. Say you have something like 'rama beats ravana using a stick'. One way of coding it is:

"%s beats %s using a %s" %(rama,ravana,stick). The translator gets the following string:


"%s beats %s with a %s" if he is translating into Tamil he will write:

"%s kondu %s yai %s adikkiraar"

which actually means: "ravana beats a stick using a rama". To help the translator, python can use this syntax:

"%(ram)s beats %(ravana)s using a %(stick)s" %({'ram':ram,'ravana':ravana,'stick':stick}). In this case the tamil translator will get things right as each placeholder is named. In my ayttm translation I am held up here:

IRC: login@server.com in order to connect as login to server.com.

(although this does not show up in the post, there is html markup in the string)

if I translate in situ it is going to be rubbish. It needs some re-engineering to make sense. Programmers should become aware of these problems and should try to make life easier for translators. After all translators are villified as lazy scum stooping to pluck low hanging fruit for cheap fame and publicity, so programmers should not expect them to show intelligence, diligence or creativity.

good and the bad
pic1
[info]lawgon
ayttm project is humming along - reached 95%, thanks to a lot of support from Chennai LUG. Should be done by tomorrow. Then review and submission. With this under my belt, I plan to tackle Sachmo next. Should get progressively easier as good translations replace the bad. With Ayttm, I got 20% automatically done and about 20% fuzzy - the fuzzy was 90% crap. And the bad news, I have always wanted to contribute to Sahana and when I heard there was a python port, was thrilled. Unfortunately they have decided on web2py - a sucky looking framework 'written by college professors' and full of buzzwords. Maybe I could write a django port?

back to translation
pic1
[info]lawgon
after a long gap I have embarked on a large translation. Ayttm. I have to combat badly bolted on i18n and some of the strings are untranslateable. Other than that it is an exciting experience - finished 53% so far. I think about 90% can be done. For the rest, the pot file has to be edited by the authors.

modelling
pic1
[info]lawgon
I normally do seat-of-the-pants programming. Write the comments first and then fill in the code. This is for new stuff of course. Old stuff is copy, paste and modify. Recently for some reason I got stuck writing something as simple as a forum. Just wasn't working out. So I thought of modelling it first. Installed Umbrello and immediately got a headache. Do I really need to learn UML? I tried in Freemind also - but it wasn't suitable. Then I installed Dia. That worked - drew my diagram. And drew all types of lines between boxes and got clear on what was to be done. In 10 minutes my forum was running perfectly and in production.

sanity at last in foss.in
pic1
[info]lawgon
I was amused to note the new venue for fsck.in - probably so that the lunatics wno conceived this abomination can be transported between their padded cells and the venue with minimum exposure to the general public.

is goog losing the battle against spam?
pic1
[info]lawgon
I have been a member of the django-users@googlegroups.com from around august 2005 using my id lawgon at thenilgiris dot com which I have had for the last 14 years. Since the id has been around so long, it is not surprising that spammers are in the habit of spoofing mails from me. The other day I got a mail from Karen Tracey who is an admin at the django mailing list, asking me if I had sent a particular piece of spam to the list and also informing me that some other admin had banned my id from the list. I asked her to check the headers of the mail in question to see whether it has come from the IP registered to my server, but she said that the headers were no longer available. Since she knew I was a long time member of the list she did me the courtesy of verifying with me and and immediately lifted the ban. I had to re-subscribe, and now, from one of the oldest members of the list I am one of the newest. Today I get another mail from Karen mentioning another piece of spam - but this time she checked the headers and found the mail was from some server in switzerland with a totally different IP. So my basic question is wtf is google up to? Do they not verify the origin of the mail? At times when sending test mails in configuring mail servers, I have sent mails with a from address not originating from the IP of the domain in question - all mail servers reject such mail. Of course I also have a beef against the trigger happy admin who banned me - surely if he had looked at my details before banning he would have seen 'member since august 2005', and if he had done a search on the list he would have found 3500 posts from me - none of them spam. So who to blame? Goog or the trigger happy admin? And what happens to my reputation?

reappy a cool conference
pic1
[info]lawgon
pycon India 2009 will go down in history as the event that popularised the new buzz word 'reappy' (according to knowledgeable people this is an acronym for 'REAP the benefits of PYthon' - but since knowledgeable people are usually jobless, this may be taken with a pinch of salt). Anyway, to come to the point, the idea of a community sponsored python conference was mooted on the Bangpypers list about 6 months back, and we decided to dive in. The main action took place in Bangalore and I decided this was reappy a good chance to flog my conference app - fossconf. So I submitted it for scrutiny, and to my pleasure it passed muster and was accepted. (this is a very unusual occurrence because generally Indians tend to sneer at any locally produced app). This was my first experience of interacting with with a non-foss group, and I had to struggle a bit to adjust to it. To my credit I stayed cool and did not lose my temper even once. During the testing period, there were a lot of suggestions, comments and criticism, by and large constructive and helpful, although some of them were totally inane. I am especially grateful to Senthil Kumaran who took 4 hours out of his busy schedule to exhaustively test out the application. I remember spending two hours from 5.30 to 7.30 am on one morning with him in Bangalore and me in Chennai, ironing out bugs and adding features.

In the foss world, each person barges in and scratches his itch - in a bumbling sort of way, things get done. Conference management software is usually under development throughout the run up to the conference, and is rarely complete even when the conference is over. The first hurdle I had to overcome is the concept in the non-foss world of 'software as a completed product'. There was an expectation that the software be completed before being put into production - rather than putting what is available in production and enhancing it on the way. Software can never be complete because one cannot reliably predict what needs may arise. Anyway it was put in production, and almost immediatly new features were required. We had to add tee shirt sizes and a privacy box in the user profile - as also the ability to print id cards (not that anyone used that feature). Then the menu system had to be restructured so that the admins could add, delete, enable, disable and rearrange menu items. And of course, we forgot to test the scheduling part of the app - when we started using it, it was b0rked, but easily sorted out. And a pretty major rewrite of the multi-author feature was also done. As I know zilch about design, someone volunteered to do the design part, but after giving a mock-up, he vanished without a trace, so I managed to put together something that looked like a design. Fortunately for me, Anand C suddenly put aside his aversion to django and chipped in with a few patches that tidied up some of the awkwardness in the look and feel.

In the final run up to the conference, the site went down a few times. The worst was the day before the conference when I was travelling in pelting rain from Ooty to Bangalore and got a call saying the site was down. I could not do anything until 9 pm when I finally reached Bangalore and set it right. So what went wrong? My logs were showing postgres and apache running out of memory and shutting down. I assumed that some other vps on the same gandi machine was getting hosed and this was shutting my site down too. I contacted Gandi, but their reply only came after the conference was over. I now realise that the site was crashing due to load. Too many people accessing at the same time. I had an alternate site ready, but unfortunately the DNS was in Anand C's hands and he was not available. Fortunately the people responsible for crashing the site were all at the conference and were unable to hit it, so the site stayed up during the conference.

As for the conference itself, I encountered reappy on the back of the volunteer who was guiding me and was wondering whether I needed to get my eyes tested. I had the two hour tutorial slot on the first day along with Noufal and Parthan, so had to leave the keynote speech halfway through to get ready. Slowly people started trickling in to the hall, I chased out all those people who had any knowledge whatsoever of python - and even then the hall was full. I gave an hour's hands on demo of the basics of python, and it seemed to be pretty well received (every one laughed at my jokes, so at least they were not asleep). Then Noufal took over for the advanced part. After the tutorial, I could not get into any of the halls, so did not get to hear any other talks. Put some names to faces over lunch and chatted with other outstanding pythonistas (mainly from Chennai) and left early. I was staying in the Catholic Club and didn't get to sleep at night because a huge party was going on. Got to the venue a bit late - Parthan was on the job doing the tutorial (first time I have seen a Chennai guy sweating in Bangalore). After Parthan finished, I did some regular expression stuff and an introduction to urllib. By then my headache had become severe and I went home. My most abiding memory is of the long Q for registration, and the fact that large numbers of people had come on their one steam from Kerala, Chennai, Hyderabad, Pune, Mumbai and Delhi. And fossconf benefited a lot in terms of new features thanks to the conference - and has now been chose for the upcoming Mukt.in in Hyderabad. Reappy and change the world!

excellent advice
pic1
[info]lawgon
http://t3.dotgnu.info/blog/rants/howto-minimize-your-value?new

we did it
pic1
[info]lawgon
pycon India 2009 happened. a resounding success - even the 2nd day which was a Sunday and Ayudha pooja also, had a fair attendence. Possibly the first community driven language conference in Asia - and not one fossil in sight! We hope to do even better in Chennai? next year.

a nice day
pic1
[info]lawgon
a nice thing happened to me the other day. I am the lead developer of the fossconf software used for pycon india 2009. The software works fine, but the look and feel is a trifle crude. I am not a designer. Some guy volunteered to do the design, gave a mock-up and vanished without a trace. I was held holding the baby, but managed to massage his contribution to make the thing look fairly ok. But there were rough edges. The other day I noticed someone had cloned the repo - was wondering why. Then I get a pull request where he says he has made a few minor changes in the html and css to smooth off some of the rough edges. I pulled it to my dev machine and tried it out - it worked! After that followed several more minor incremental changes - and the whole look and feel has improved. What impressed me was that a senior person like this had taken the trouble to make minor changes and commit them - rather than preach. Mercurial is ideal for this sort of small incremental contributions which are the life and soul of the foss developement methodology. You do not need to beg for commit rights - no need to submit patches and no need for the developer to apply and test patches. Application of patches is a real pita sometimes as line numbers in your version and his version may differ, screwing up the patch. All you need to do is clone his repo, make and test the changes and ask him to pull. He pulls, it works, he pushes to production. Doesn't work? no sweat, he may debug it or he may pass it back to you. Either way it is a clean way of doing things , unlike svn where the choice is either commit rights or patch. And even if I trust a person it is silly to give commit rights to a one-off contributor.

google adsense woes
pic1
[info]lawgon
I had a google adsense account - I can't log in now as they have changed the login from username to emailid. And I cant create a new acount because they say I have on already. And I cannot retrieve my password because now login is to emailid and my password was for username. So I take a different username and email address. Rejected - they want me to put a page on the site declaring I am the owner etc etc. That's done -rejected again. Incomplete address!. Actually the address is fully complete, but to make them happyI put a door number also. Rejected again - company name incomplete. The company is a sole propietorship firm - and the name is perfectly valid for the purpose of business, bank accounts etc. Now I am stumped - the checque will come in the company name - if I add some embellishment to satisfy google - will the bank accept them? And I have no avenue to explain this to google.

mailing list etiquette
pic1
[info]lawgon
Now that FOSS is here to stay one sees all sorts of people on FOSS mailing lists. Like in all other walks of life these people never bother to read rules and guidelines for posting. You see the same thing on roads where people are unable to distinguish between a horn and a brake. So people who have learnt how to subscribe to a list and how to post a message on the list are instant experts. Top posting, asking stupid questions, not giving enough information for an answer, blindly posting google search results in an answer without bothering to read the search results - the list is endless. There is even one joker who licenses all his mails under CC-SA. Most of this is done out of ignorance - and polite correction usually works. But how to deal with the diehards who do all this deliberately thinking that their way is best - and to hell with guidelines that have evolved over the last 20 years? In the old days they were flamed, moderated or banned. Flaming does not usually work with these guys and banning and moderating should be reserved only for spammers and bots.

There is another way. Give two polite corrections. Then one flame. If that doesn't work. Ignore them. IRC has an ignore button. Mail clients have filters - send their posts directly to trash - where they belong and you never need to get annoyed with them again.

btw, I found another nice thing about interleaved posting. It is always a good rule to read what you are replying to at least twice. Interleaved posting forces you to do this. First you read it. Then you read the portions you have selected while you select them, then when you actually reply you read it again - so you wind up reading it three times. The top poster reads it once, and when replying does not have the matter in front of him and has to rely on his memory and the replies will often be out of context - of course since all die hard top posters have a photographic memory (or at least they think they have) they do not worry about this.

ready made css
pic1
[info]lawgon
I have always maintained that the content of a site is more important than looks - as a result all my sites look horrible even if the content is up to date. Unfortunately people get put off with 'bad' design. There is a difference between design and looks. The best looking sites are also often impossible to navigate. Easy to get lost in them. Anyway I have finally decided not to waste my time in writing my own CSS and imported a ready made css - now it is starting to look good and I can concentrate on content and ease of use: http://thedownstownchronicle.in/ and http://demo.ilugc.org.in/

coding xml
pic1
[info]lawgon
although I use geany, a lightweight IDE, I have never really used most of the features. Reason is that I work on python scripts which are mainly only few screens long. I recently had the experience of adding to an xml file that was several thousand lines long. The trouble with xml is that it fails silently, so very difficult to debug - and very difficult to find one's way around. It is then I realised the importance toggling markers. I offer a silent tribute to the courage of people who code C and Java with 10s of thousands of lines of code.

scripting
pic1
[info]lawgon
it is a long long time since I wrote a python script - never realised how rusty I am. All I had to do was a small script, read the database, select all the users who have joined the planet, format the info ahd write it to the config file. I found I had forgotten the basics of python - took me nearly 45 minutes to write it and get it to work. There is no substitute for daily contact with the language. Since I am an on-off coder, every time I write code I spend most of my time relearning stuff that I have learnt a hundred times before.

(no subject)
pic1
[info]lawgon
as everyone knows I am never happy if I do not put up a new website every week. Here are my latest offerings
http://thedownstownchronicle.in
http://xlquest.net

Home