Badger Alert!

Calculating CBSE Results : Ruby to the Rescue!

Posted by: generalmaximus on: May 30, 2008

The CBSE class 10 and 12 results have been out for a while (and so have I). They’re (e)mailing out large text files containing school-wise results if you happen to have your school code (it’s written on your admit card as “School Number”).

Large text files containing statistics and I don’t do anything with them? Impossible. I whipped up a quick Ruby script that can calculate and display subject-wise averages, given a  text file with the results. Here is what it comes up with when I feed it the class 12 results (for the science sections only) for my school (Bal Bharati Public School, Pitampura) :

English average = 69.7157894736842, max marks : 85
Math average = 84.1414141414141, max marks : 100
Physics average = 81.5959595959596, max marks : 98
Chemistry average = 79.8484848484848, max marks : 98
Net PCM average = 81.8619528619529

Geez, talk about accuracy! The class 10 results are as follows :

English average = 81.0955223880597
Hindi average = 70.4805970149254
Math average = 83.7582089552239
Science average = 83.2626865671642
Social Science average = 82.4238805970149

(If you’re a DPS student, you’re probably laughing at these marks right now.)

I’m not posting the script here, partly because it has the following problems :

  • Horrible coding style.
  • Non extensible, non generalized parsing of the file. In fact, I just read the file into a string, iterated through each line, called split on the line and grabbed the marks from the resulting array. It doesn’t take into account the subject code et al.
  • Can’t calculate averages for commerce/humanities students.

All those problems are a result of the fact that the script was written in less than 10 minutes. I just wanted to know where I stand compared to the rest of the school.

If you want the script badly, leave your email in a comment and I’ll try to get back to you. Mind you, I’ll try. Or write your own. It’s easy enough, if you happen to know Perl/Python/Ruby.

Peppy : An XEmacs Like Editor in Python

Posted by: generalmaximus on: May 17, 2008

Peppy is a very nice XEmacs like text editor written in Python using the WxWidgets toolkit. It’s a godsend for people like me who need to fully control their text editor, but do not want to learn a completely new domain specific language like Elisp or Vimscript. Now I can write plugins for my text editor using Python! What could be better than that?

For the curious can-I-get-it-now? people, even though Peppy is ready for everyday use, it still has some minor bugs and caveats. Nothing major, and nothing that can make you lose your work, but it still needs a bit of work. Most small bugs would probably be squashed by the next version, so hold on just a bit if you don’t like alpha/beta quality software.

Visual C# Express Edition – Looking Good

Posted by: generalmaximus on: May 8, 2008

I’m not really a Windows person. I prefer to use Linux simply because of the large repository of free development tools it offers. I’ve never had to dig too much to find the library/IDE/text editor/compiler/interpreter I wanted.

Today I just wanted to browse around the web a bit, so I booted into Windows (which I normally use for gaming only). I happened to stumble upon the development section of Microsoft.com (through Wikipedia). Specifically, this page. The guys have decribed their products in such a mouth watering way that I just couldn’t resist downloading the Visual C# IDE, simply to see what the hype was all about. It took a while for the installer to download all the components of .NET and install the IDE.

I was thrilled.

I was enchanted.

Ketchup.

Really, Visual Studio has improved quite a lot since I last used it. It’s a lot faster, the project management is a lot smoother and the coding experience is absolutely the best I’ve had since ages. If this baby ran on Linux, I’d probably be using it for everything I do. But it doesn’t, which is a shame. There’s no way I’ll give up on my solid open source development tools and lock myself into Windows just so I can use a fancy IDE. But I swear that Visual C# is absolutely the best thing to come out of Redmond since, well, ever.

Now I know why Linux folks are so anti-IDE. The IDE’s available on Linux are simply not good enough. Most of them miss the entire point of having an integrated environment, and simply limit themselves to be fancy text editors with a few compilation features thrown in (something which Emacs can handle much better than anything in existence).

For me, using an IDE means being able to quickly write and test small test applications without the hassle of setting project parameters or customizing makefiles. Throw away apps should be “throw away” in the true sense. It’s excruciating to spend an hour on a trivial test application just to throw it away when my experiment is complete. For larger applications, the IDE should take away the hassle of maintaining source files and related makefiles. Source control should be dead simple.

Now I know why I use an advanced text editor to write my programs. I just want to write a simple 50 line script, test it, use it, and throw it away after it has served it’s purpose. I don’t want to sit around messing with a complex IDE. Either make the IDE dead simple for a newbie, and hyper advanced for the hardcore program (like VS does), or fade into irrelevance.

Anjuta/Eclipse/KDEvelop, I’m looking at you.

PyS60, Woo!

Posted by: generalmaximus on: May 5, 2008

I downloaded and got Python running on my mom’s old Nokia 6600. Heaven! I can actually program on the move! The best part is that PyS60 is officially supported and hence has a large, complete and stable API that I can use to control every aspect of the phone. The only qualm is that PyS60 uses Python 2.2, whereas the latest version is 2.5 with 3.0 just around the corner.

I also managed to find a little programmer’s text editor for the phone with syntax coloring and automatic indentation that I can use to write Python code. Granted, it’s difficult to write anything on the 6600’s numeric keypad, but it’s a nice feeling nonetheless. For the first time I’ve been able to program my phone like I program my PC.

That said, Akshay is buying a Chinese mobile, which is bound to have some sort of Linux distro on it. He’ll probably manage to hack it and get Ruby running on his phone, which would be killer. He’ll probably have to write some C code to interact with the hardware, though.

All of a sudden I’m interested in “embedded development”. There’s a whole range of things one could do with a programmable smartphone. Plus, it feels like I’ve gone back to the year 1997, with crappy Windows 95, slow hardware and lots of shareware programs written in Delphi.

Ahh, the sweet smell of a 105 megahertz processor …

I Want to Go Insane

Posted by: generalmaximus on: May 3, 2008

I want to plunge into computer science, and I want to do it now. I’m sickeningly tired of this competitive examinations thing. I just hope it gets over soon, so I can get on with my life. Just another month to go …

It’s been more than an year since I learned Python, and I still haven’t put it to any use. Preparing for college entrances is simply eating up all my free time. Once I’m done with them, I’ve decided to go insane. It’s going to be a very nice feeling.

The first thing I’m going to do is get as much math into my head as possible. I’ve been looking around and, while not directly useful, math does help you solve programming problems. I’m going to push the barriers of what any sane person would (or could do) with math. I have the entire world right here in my living room, so there’s nothing stopping me from doing what I want to.

The second step would be to eat, drink and breathe Python until it comes as naturally and easily to me as English. I suppose I’ll need a good CompSci text to chew through, since I already know all the syntax.

That was phase one. Phase two would involve moving down to C. I already have a good book on C, which I’m going to read cover to cover. Phase three will be learning assembler.

Obviously, I’ll be solving a lot of programming problems in the process. Luckily enough, the Internet holds a huge repository of programming challenges to get me started. Once I solve some of those, I’ll move on to more difficult CompSci texts like the SICP.

I just hope this last stage of torture gets over. School has lasted much too long, it’s about time I had my way.

Killer Combo : Zenwalk With XFCE

Posted by: generalmaximus on: April 8, 2008

A couple of days back I broke Ubuntu, as I usually do with all my tinkering and probing. Instead of just reinstalling the system, I decided to give another distro a spin since Hardy would be out soon anyway. The distro I chose was Zenwalk. I must say I’m never going back to Ubuntu again.

Never has my desktop looked so beautiful, and it has certainly never been this snappy since I bought it one and a half years back.

Zenwalk is based on the most UNIX-like system of them all - Slackware. Like Debian, Slackware is one of the oldest distributions around, and focuses on speed and stablity over new features. Zenwalk has simply taken the Slackware base and added a nice GUI + several configuration tools on top to produce an ultra fast and ultra stable system. On my AMD 3500+ with 1GB RAM, Zenwalk is usable in under 30 seconds. Ubuntu, on the other hand (along with Windows XP and Windows 2003 Server), took about a minute to be completely usable.

I had tried XFCE before on Xubuntu, but it wasn’t the real XFCE. The Ubuntu developers had just modified XFCE to look a bit more like GNOME and added all sorts of useless bells and whistles to the system. Not Zenwalk. You get all the goodness and snappiness of XFCE along with a great selection of packages and development tools. After using Zenwalk I realized that all that hype surrounding the new features Ubuntu has been introducing in every version is unjustified. What we need is less features, and a system that just works.

Overall, I’m highly impressed with the beauty, simplicity and speed of Zenwalk (and XFCE). I’m currently using Opera to browse the web, and listening to music using the Audacious media player. I can open 50 new tabs with absolutely zero hit to my system performance. I can open up several applications at once – Pidgin, Transmission, Brasero, AbiWord – and start working with them and my system would still be as snappy as ever.

As a sidenote, I’d like to mention that XFCE manages the desktop much better than GNOME or KDE. Using the XFCE desktop is not tiring. Everything is as you expect it to be, and there is a minimal of visual noise. Moreover, I can set the taskbar to only show the icons of the minimized applications instead of the entire titlebar text. This significantly affects my brain in a positive sense, since the desktop feels uncluttered even with 10 applications running. I have two workspaces, but I’ve never yet needed to use both of them together because the interface by itself no manual organization of windows and running applications.

I realize this post has not come out very well. Well, what do you expect? I’ve just woken up.

Need to Go Functional

Posted by: generalmaximus on: March 31, 2008

I’ve been taught C++ at school (although I learnt all of it in class 11th) and I’ve learnt C on my own. I’ve also learnt most of Python, and with some help from the online documentation, I can hack together whatever scripts I want to.

Now I love Python and C (don’t talk about C++, it’s just plain crap). I’ve been thinking a lot about Ruby and finding it nice to program in. But I think I need to learn a functional language right away. Why? Because of two reasons – one, colleges don’t teach any language that doesn’t get you a job right away and two, functional programming looks fun, at least from what I’ve read about it.

I mean, anybody can put together a sequence of instructions, given enough training. Just look at the Java and .NET code monkeys you can get a dime a dozen. But functional programming, that’s for people who are really into computer science. Functional programming borrows heavily from mathematical concepts (as I inferred with my very brief exposure to Lisp), and math is good. Math is solid facts, logic. Math can be fun, if studied the right way. You can’t really go wrong when you have a set of well tested equations and models in your hands. Of course, when I say math, I don’t refer to the crap they teach us at school. That’s not math, that’s learning equations and plugging in values to get answers. Predictable stuff you can’t really have fun with.

I’ve seen that well designed functional code is much shorter than procedural/OO code. Not that I understood much of it, though. Moreover, with functional programming you can sit down and design every small unit, piece by piece, on paper and test everything out before you type the code into your editor. After all, most of it is just mathematical equations.

Functional programming is not easy. It forces you to think in different ways. Anyone can write the steps leading to a valid output, but not many people can sit down and design a fully working recursive function. I want to be able to do exactly that.

I want to see the limits of my mind. I want to bend it and twist it until it becomes something completely different. Right now I’m just looking for good learning resources. I’m reading this Wikibook on Haskell. Let’s see how successful I am at learning Haskell, and at designing actual working programs with it.

The Road to DCE (and AIEEE)

Posted by: generalmaximus on: March 28, 2008

I just joined a crash course for “IIT/AIEE/DCE/VIT etc.” at a tution center nearby. They call themselves an “institute”, but the place is relatively new with very few students, so it’s more like a tution center. Even the walls still smell of wet paint (when I say walls, I mean the large wooden plyboards these guys are using as walls to separate the humoungous hall into classrooms). I could have joined a “reputed” tution center (the word “institute” is an overkill for these sick places) like Narayana or FIIT-JEE, but the truth is that the underdogs always perform better in an effort to overtake the big boys. And that’s exactly what’s happening. The students who joined the Narayana crash course are returning disillusioned and depressed. I, on the other hand, am pretty happy with the place.

In the two classes I’ve attended (and the previous years’ sample papers I’ve taken the time to finally take a look at), I’ve realized that the DCE exam will not only be a test of your l33t PCM $killz, but also a test of strategy. “How do I take the exam?” is a more important question than “OMFG! I don’t know waves! How the fuck am I going to complete the course?!”. Well, STFU and, for once, don’t complete that waves chapter. Polish the stuff you already know, like electrostats and stuff. They say 60% of the paper is from class 11 syllabus, but this information comes mostly from rumours and from Ravi Raj Dudeja who, unfortunately, is dead. I’m waiting for Apoorv/Sneezy to verify this information.

For AIEEE, there is less hope because there is less than a month left for preparation. But if I complete the class 11 course and increase my problem solving speed, I might be able to get a pretty nice rank. How? This is how : I already know the entire class 12 course, and the tution center is going to polish up the class 11 course. In a way, I’ll know how to attempt at least 80% of the paper. Considering the fact that I’m extremely good at physics and passably good at math and chemistry, I’m sure I’ll be able to somehow complete a large part of the paper. I can get a rank in the range of at least 15-20K, which will be okay by me because at 15K I can get into one of the private colleges in the NCR.

I have a battle plan. Again, I’m hoping that Apoorv/Sneezy will come along and refine it. They have taken many tests at Narayana and can should help me out with the coming exams. Here’s the plan :

1. Apoorv said that doing 70-80% of the paper is good enough. That means out of 120 questions, I need to do 84-96 questions. This will be my target. I’ll try to complete these many questions in 2.5 hours, leaving the ones I’m not sure about for the last 30 minutes.

2. I’ll do the paper subjectwise in the order P->C->M since my physics is the strongest. Chemistry and math are pretty much the same, but chemistry might have more conceptual and graph based questions so I’ll do chemistry first. Moreover, I’ve heard that AIEEE math is a bit tough. So math comes at the end of the list.

3. I’ll do the paper in 3 iterations.

4. In physics, I’ll do the graph based, conceptual and direct questions in the first iteration. Direct questions are the ones involving simple differentiation, maxima/minima or direct application of some formula. In the second go, I’ll do the questions I know I can answer, but might take some time or thinking.

5. In chemistry, I’ll do graph based questions and direct questions in the first go. Direct questions are generally from organic or inorganic chemistry, like naming a reagent, naming a given compound or finding the type of hybridization. I’ll leave physical for the second iteration, not because it’s difficult but because it involves more numerical calculations (and maybe even looking at logarithm tables, but I’m not sure about this).

6. In math, I’ll do those questions first for which I definitely know a formula, trick or shortcut (and in math, there are many of these questions). Wherever I see a lengthy calculation or expression, I’ll leave that question for the second iteration. Now, I’m not sure if I’ll be able to do all or even most of the math questions, so the strategy for this subject is hazy at this moment.

The above should take at most 2 hours 15 minutes to 2 hours 30 minutes.

7. In the third iteration, I’ll try out the questions I left before, again in the order P->C->M. Here, I’ll try to bring my score up to 85-90 questions or (if I still have time) more. I need to leave at least 10 minutes for checking whether I’ve marked everything correctly in the OMR sheet (I’ve made the mistake of not checking this before).

That, broadly, is the strategy. 100/120 correct means I’ll definitely make it to a nice college. 80/120 means I might make it somewhere. Less than that, and I’m dead.

For all I know, this strategy might be completely wrong. If anybody reading this post has given (and succeeded at) any competitive exam, refine this strategy for PCM’s sake (and post a comment).

Of course, Apoorv should has to spread the link to this post via e-mail.

People = Shit

Posted by: generalmaximus on: March 22, 2008

Only when you get to meet them do you realize this. People = shit. Now I know why I’m not social, or why I manage to get along with only a very few people.

People don’t value life, people don’t value your work, people don’t value you. All that they want to do with you is to judge you relative to their own son/spouse/relative. Don’t they realize I’m a unique person with unique tastes and temperament? I guess not. All their lives most (all?) of these people have been knowing people without really knowing them. They’re shallow minded people who are too wound up in the world to care about small, simple things that really matter (Yes, it’s only and only the small things that matter. The stray puppy on the road matters. Iraq, the United States of Something, Bill Gates, Dalai Lama … worthless pieces of shit).

What happened? Why am I so annoyed? It just so happens that most of my relatives are annoying assholes who want to “guide” me. Hell, my own parents have never tried to guide me (and I thank them for this ; I’ll thank them my entire life), then what right does my aunt, uncle, uncle’s brother-in-law’s retarded sister or some fucked up guy who seems to have jumped right out of a self help book have to “guide” me? My parents have let me make my own decision. My dad has a business which is growing pretty large and needs looking after. He has never told me to forget about CS and start studying commerce.

I have these cousins (one is a recent CS grad, one is in college studying to become a dentist) who treat me very nicely, asking me about how things are going with me, asking me about the books I’ve read recently, about the stuff I like about computers. The one who’s a CS grad shows me her projects and tells me about things she’s been learning. Their parents are just as nice. They know all about me and my tech/reading obsession. None of them has ever interfered with my life, never tried to guide me or judge me. I just go to their place (they have a huge mansion) and relax.

Then there are these other relatives. There’s this person who I’m supposed to respect and not shit on, but I’m going to do it anyway. She keeps asking about my academic performance, what colleges I’m applying to and what I’m going to do about my entrance exams. She’ll try to act like she knows a lot about technology, because her work involves computers, but she’s the sort of person who can’t even manage to install spyware on her computer because the only website she knows about is Google.com (and doesn’t really know how to use it). She’ll keep telling me that I’ll fail if I don’t join an institute for entrance coaching. She kept discouraging me from going to the US to study and made up arbritary reasons for it (the person who really stopped me from going to the US only said “motherfuckers go abroad to study” and left the matter at that). She will refuse to appreciate me as I am, and try to push her opinions on me. She’s the kind of person who believes that people younger than her aren’t entitled to their own opinions.

Let’s call the next person I’m going to talk about Mofo (MOtherFucker). Mofo thinks he knows it all. He claims loudly that he knows how to judge people. He acts like a “leader” within his family, even though there are nicer, more intelligent people in his family. He walked into my room this evening, looked at my bookshelf and asked me whether I had read all of those books. I had. He then asked me whether I read self-help or personality development books. I’m seventeen, for crying out loud. I’m perfectly happy, living with the most perfect family on Earth. I’m going to need to read self help books? For what? Only depressed idiots read those books. And “personality development” is a term coined to leech people who have low self esteem of their money. I didn’t tell him this, of course. I told him that I only read fiction.

Next, he asked me whether I had any particular interests, a particular direction I wanted to take my life in. This was obviously too philosophical for me. I don’t like sentimental, philosophical crap. I told him I liked computers, that I wanted to go into software. “What exactly do you want to do in software?”, the idiot asks. Now, am I expected to tell a n00b about embedded programming, language design and artificial intelligence? Nope. I just said I like programming. He said, “What do you like in programming?”. Idiot. He probably didn’t even know what programming is. I’m not yet interested in one particular field of CS, and I told him that. I said I would probably gain exposure when I study CS. He insisted that I should know what to do right now. The most irritating part was that he told my parents that I need “direction”. My parents only laughed, and are still laughing at the idiot.

Mofo went from person to person in my house and tried to interview them, talk to them and said that he is a “Jack of all trades” and can “do everything”. He didn’t even sound like he was remotely educated. If I have ever seen a smartass, it has to be Mofo.

As an aside, I’d like to mention that I’m glad I have Ankush as my brother. Everything philosophical Mofo said, Ankush turned it into a joke. Every time Mofo tried to “guide” him, Ankush made some lame comment that made everyone in the room laugh at Mofo. Pretty soon, Ankush was the one asking questions and Mofo was the one getting unnerved. In a span of fifteen minutes of talking to him, Mofo was so mortally afraid of Ankush that he refused to even come into my room. Having a smartass, big mouthed, insulting brother can sometimes be an advantage.

These are just accounts of two really annoying people. I have seen more than I can count. Here’s a small list of irritating thigs :

1. I got a dog. I love him. I told this person at school about my dog and he said, “A dog? You bought a dog? WTF, dude! You should have spent the money on something cool, like a mobile phone or a video game console. A dog?”. He also likes Akon, and listens to what his parents say. He’s going to remain a nameless fool for the rest of his life.

2. People are surprised at my dad’s garden. Shows how much time they spend on what they really like. Probably they don’t like anything at all, and are content to sit around and watch TV. No dreams, no hopes, no aspirations. IQ = 0.

3. People smoke, take drugs, drink alcohol. That’s not cool, that’s just trying escape from reality. Self destrucive entertainment, that. I know two people who are very excited about smoking cigarrettes. I’ll let them smoke. They’ll probably come to their senses when they’re dead.

4. For most people I know, having fun means dancing to loud music in a disco. Do people really like rubbing their dicks with the asses of people they aren’t even acquanited with (and who probably have AIDS anyway)?

5. On more than one occassion, I’ve been ridiculed for watching cartoons because “they are for kids”. STFU, asshole. Cricket/football is for goons who think with their dicks. Cartoons are for people who just want to have fun. Apoorv doesn’t like cartoons, but he has never laughed at me for watching them.

6. Kitallis is depressed because if he doesn’t score well in the Boards, his relatives are going to think he’s dumb.

7. People keep telling me parents not to worry because I’m “intelligent”. I beg to differ. As of now, I’m a pretty average guy. It’s their kids who are dumb and retarded. Take away their shitty mobile phones, block access to Orkut and Hi-5 and turn off the fucking TV. Then watch them do what you never even imagined they can do. Technology, unless used properly, is evil.

8. There are these stupid teachers back at school who have ego problems. I won’t mention them again (read the archives). It’s just sufficient to say that if you treat me like a person, I treat you like a person. Our math teacher did exactly that, and every person in the class respects him. Mr. R.K. Gupta is the best teacher ever.

9. I go for a walk after dinner. Every night I see these two girls (they’re probably my age) walking with their family with a mobile phone in hand playing crappy, blaring music. Can’t people let go for once? Pop culture is killing all the good things in life.

I just had to get all this out of my system. I’ve never ever believed anybody to be below or above me, but I guess that is going to change pretty soon.

I’m a person, not somebody who should be “guided”. I’m not a consumer. I’m not a “student” who’s supposed to believe exactly what you tell him to. I’m a real, living, breathing person who has his own talents and weaknesses. I have my own dreams, so you can fucking keep yours in your own head and not force them on me. I form my own opinions, and I’ll be damned if I accept yours without thinking about them.

Stop. Fucking. Judging. Me.

STFU, have a glass of lemonade, sit on the grass and relax.

The Ruby Programming Language

Posted by: generalmaximus on: March 21, 2008

I just read the first chapter and I swear it’s the best programming book I’ve read since The C Programming Language. I had been looking all over the web for a decent enough Ruby tutorial that would teach me the complete language and at the same time not be full of shit. I regret to say that no such tutorial exists. I did try to read the Poignant Guide but I kept reading and re-reading the same paragraphs over and over again purely out of literary interest. The book is so damn funny that I forget about learning the language and focus more on the wordplay. Obviously, I couldn’t learn Ruby.

After reading the first chapter of The Ruby Programming Language, I know the basic if..else and looping constructs, I know how to define functions and classes. I how to do operator overloading and about enumerable data types. I know about anonymous lambda functions and some basic uses of the each, collect and inject methods. How cool is that? It’s the second book since The C Programming Language where the code examples actually make sense and teach you something you didn’t know. In fact, in this book code speaks louder than words, just how I like it.

This is arguably the best book if you want instant gratification, but before reading it you will need to know something about programming. Knowledge of any programming language will be helpful, although you must know your OOP concepts thoroughly. That’s it, really. Even a rudimentary language of C++, Python or Java will do. For those coming from functional languages like Haskell, Lisp or ML, the first chapter will be a breeze.

I’m loving this book. Low on crap, high on code.


  • tanya: i like shin chan very much
  • tanya: hey ringet , how you are talking. youalso have no right to speak like this to hungama channel,by the way from where are you.from india, if yes then
  • tanya: i like hungama channel the most i want that cartoons of that programme shouuld come to my house