A few bad days

Standard

“Choose life. Choose a job. Choose a career. Choose a family. Choose a fucking big television. Choose washing machines, cars, compact disc players and electrical tin openers. Choose good health, low cholesterol and dental insurance. Choose a starter home. Choose your friends. Choose leisure wear and matching luggage. Choose a three-piece suit on a hire purchase in a range of fucking fabrics. Choose D.I.Y and wondering who the fuck you are on a Sunday morning. Choose sitting, watching mind-numbing spirit crushing game shows stuffing fucking junk food into your mouth. Choose rotting away at the end of it, pissing your last in a miserable home. An embarrassment to the selfish, fucked up brats you have spawned to replace yourselves. Choose your future. Choose life.”

Well, that is from the opening scene of the best movie ever made: Trainspotting. That being said, the last few days have been an utter devastation to the above “regime”. So I took a detour from my usual ramblings and started working on a Perl project called “Complain management system”. It’s not a big fucking deal really, but this is my first commercial project in Perl and it is quite simple. To keep things simple and clutter free (this is not a tutorial…), please refer to this tutorial for details.

The requirements are as follows:

  • Perl. On Linux systems, you must have it installed already. If not, use your favorite package manager (I use apt) and install it. On Windows, go for Strawberry perl.
  • Catalyst. Catalyst is an agile MVC framework written in Perl. It is very robust and increases the development speed considerably. You can use CPAN to install it.

I’ll assume that you already are a Perl programmer because I cannot really get into the intricacies as such. I’ll directly start with how to use the Catalyst framework to make a small web application. The source code will be upped on git.

Now exactly like Mark Renton, I chose not to choose life. I chose something else. And again like Mark Renton, there were no reasons. Who needs reasons anyway when you got weed? The month that started with a good bright fucking smile on my face ended with me fallen on the freakin’ road about to be bowled over by a double fucking decker bus.

“Goa! Dude I have 5 days off and I’m not fucking them up eating at the miserable mess food you love to stuff your mouth with!” said my friend. So we went to Kashid. One of the best trips of my life. Starting with the ferry ride from Gateway of India, the journey was memorable… weed, beer, beach, silver sand, moonlit night, high tide and the cool nightly sea breeze. The water was fresh and sparkling right until the moment I lost my phone.

So starting with starting to write a web application in Perl. I’ll be using Linux obviously so all you Windows lovers are on your own. Open your terminals and fire off:

code-ninja@GeniuSisMe:~/Projects$ catalyst.pl MyApp

This will dump a long output which will result into a directory being made in your PWD (mine is Projects) by the name “MyApp”. When you change into the MyApp directory, you’ll see that there are some sub-directories and some Perl scripts. The “lib” directory will contain your code, the “root” directory has all the HTML code, the “script” directory has generated scripts to help you test and develop your application.

MVC is an acronym for Model View Controller architecture. You can read about it on Wiki. Essentially, it is a paradigm which divides your projects into three modules namely Model, View and the Controller. Model is the database, View is what you see in the browser and Controller is the bond between View and the Model. Lets make a Catalyst Controller. Fire off:

code-ninja@GeniuSisMe:~/Projects/MyApp$ perl script/myapp_create.pl controller Complain

It will again dump some output which essentially will generate a template controller for you to play with. Open “MyApp/lib/Controller/Complain.pm” in your favorite text editor. You’ll see just one sub-routine (“index”):

sub index :Path :Args(0) {
    my ( $self, $c ) = @_;

    $c->response->body('Matched Complain::Controller::Complain in Complain.');
}

This is supposed to be programmed by the developer. You can add more complex routines and stuff you want to do with the data.

But no! I will not give up! It was just a phone I lost! For a brief moment, I ate like a fucking pig and worked out at the gym. Went out and got fucked up without having any fucking idea about my miserable and depleting funds

“Lets go out and eat!” said Dang. I acceded. The Baghdadi restaurant in South Mumbai is awesome. Order a Chicken Curry and the guys will serve you with a whole chicken floating in a decadent curry. Whole… full, not cut. One big fucking piece of the meat you love to devour. “Lets go to Malabar hills and smoke up!” said Sammy. So we went to Malabar hills and smoked up. Came back… there is only 100 bucks in my account and there are 2 full weeks before I get my salary and I live in Mumbai. Fuck.

And so started the miserable week of utter penury. No food, no outing, no beer and only weed. No fucking idea about how I’d manage the 2 weeks, I give up eating like a fucking pig and working out at the gym. I give up taking a bus to work and started walking 3kms to reach my office. No money means no food during lunch time… not even a freakin’ banana.

So lets see… Now that we know how to make a controller, we will see how to make a model and a view. We write a small SQL script to make a database. Note that I’m using the SQLite3 database and the commands I fire will be specific to it.

We make a table in our database which will store user’s complain amongst other things.

PRAGMA foreign_keys = ON;

CREATE TABLE complain (
    complainID INTEGER PRIMARY KEY,
    userName TEXT,
    userAddress TEXT,
    userContact TEXT,
    productSerial INTEGER,
    productType INTEGER,
    productMake TEXT,
    complain TEXT,
    status INTEGER -- 0: open, 1: processing, 2: closed
);
INSERT INTO complain VALUES(1, 'Code Ninja', 'Andheri', '98111111111', '0112358', 'Laptop', 'HP', 'Screen Crapped up!', 0);

save it under any name you want (I called it complain.sql). Then give it to your database engine so that it creates a table.

code-ninja@GeniuSisMe:~/Projects/Complain$ sqlite3 complain.db < complain.sql
code-ninja@GeniuSisMe:~/Projects/Complain$ sqlite3 complain.db
sqlite> select * from complain;
/* whatever output */

To enable the model, we say:

code-ninja@GeniuSisMe:~/Projects/Complain$ perl script/complain_create.pl model DB DBIC::Schema Complain::Schema create=static dbi:SQLite:complain.db on_connect_do="PRAGMA foreign_keys = ON"

Don’t worry about the complex commands, you don’t really need to know them. I know what each of the commands mean but it really doesn’t matter if you don’t. Now, if you look in the “lib” directory of your project, you can see a new sub-directory called Model. Open the Perl module you see inside it. It has a Perl representation of the data columns you just made in your SQL script.

The mess where I eat refused to give me any credits because I was already in debt to them for 20 freakin’ bucks. But I disabused this nice cigarette shop guy from not giving me credit and coaxed him for my constant supply of tetra-pack milkshake and cigarettes. So, no phone, no money, one milkshake and cigarettes to go through the day. Ripped my landlady off of 500 bucks (never to be returned) and some more out of my colleagues at work. They are too friendly and don’t expect things back… good for me.

Under such conditions, the grass was a luring distraction. When you are on junk, you have only one worry… scoring. When you are off it, you are suddenly obliged to give a fuck about all kinds of things. Got no money, got no girl… about human relationships that don’t really matter. So I gave in to my senses and rolled a joint and took a long fucking drag.

And that long fucking drag could not satiate my will of fucking myself up. Its never enough… you must go out and fuck everything all over again. You know you cannot afford it but you cannot also ignore the craving. To top it, the attachment, the feelings I had for the one girl I fell for became overwhelming… I missed her, way too much. So I get higher than usual and planned to go out (knowing that I haven’t got any money). Got on the wrong bus and I stepped out of it in the wrong way… against the direction of motion. Slipped and the road was thick with traffic as it was peak traffic hours. Saw death, right in front of me… a red double decker.

For the view, we will need a few more things. First we will need a view controller that will to and fro the data between Model and the HTML web page. Second, we will need a page template that will be rendered as an HTML page by the Catalyst engine. For the template, we will use the Template Toolkit along with jqDock and a bit of jQuery. To make a view controller, fire off:

code-ninja@GeniuSisMe:~/Projects/MyApp$ perl script/myapp_create.pl view TT TT

This will create Template Toolkit view that the Catalyst engine renders into a complete HTML page. It will also create another sub-directory under “lib” called “View”. You must follow that tutorial I linked above because I’m not writing a fucking tutorial. I’m just elucidating what all is there to make a small web application in Perl.

And in this situation, the quote “A friend in need is a friend indeed”, was tested. Found a gem :). Thanks to the guy that I was able to survive this state of penury without affecting all my debauchery. Now, I have got money… got a bonus from work (for my work with this application) and now…

“The truth is, I’m a bad person, but that’s gonna change. I’m gonna change. I’m cleaning up and moving on. Going straight and choosing life. I’m looking forward to it already. I’m going to be just like you. The job, the family, the fucking big television, the washing machine, the compact disc players and electrical tin openers, good health, low cholesterol, dental insurance, mortgage, starter home, leisure wear, luggage, three-piece suit, D.I.Y, game shows, junk food, children, walks in the park, good at golf, washing the car, choice of sweaters, family christmas, indexed pension, tax exemptions, clearing gutters, getting by, looking ahead, till the day you die!”

The code can be found here. I haven’t uploaded the SQL script I used but you can make it yourself. The README has everything you need to know about how to run the application.

Advertisements

An idiot’s gudie to socialism

Standard

Hello everyone :). Well, since my last post, I have got 10 more follows. Behold the fields in which I grow my fucks, lay thine eyes upon it and thou shalt see it is barren (I like you guys even if I haven’t met you, you are awesome… thats my way of saying thank you 🙂 ). Anyways, today we will learn how to socialize and analyze an Allwinner A23 tablet.

That girl I really like… she says I should go out and socialize. I thought I should give it a try. So this Sunday, I FORTUITOUSLY, get out of my room and see a random guy coming downstairs from the room above. He has a cycle… lets try him.

Me: “Hey… hi. You live upstairs. Did you just move in?”

Him: “yea… you live downstairs?”

Me: *thinking to myself* obviously you moron. “Cool… do you mind if I hangout with you guys? I’m kinda new here and don’t have much friends and all…”

Him: *thinking to himself* what kind of a moron is he? “Oh yea! that’d be cool!”

So… I socialized! We hung out for a while, had a fag or two and then dinner. He is quite cool. He is a mechanical engineer and I have no idea how I know that he has been into 2 relationships.

So this new tablet I got at work. It runs on an Allwinner A23 SoC and Allwinner boasts that it is the most efficient SoC ever built for a tablet device. And their claim ain’t faulty. In the “quick boot mode”, it takes less than 3 seconds for the tablet to boot. The “high speed mode” is blissfully fast but the problem is, the tablet is not recognized by ADB.

Luckily, the vendor managed to, somehow, install Debian LXDE into the NAND partition and we can select to boot Debian in the “Backup and reset” option under Android settings. Thats 1337! I wish I could do that but since I cannot right now, we will try and see what all drivers and libs Debian loads. We will then hack the drivers (next post probably) and have a powerful fully dual booting tablet at our disposal.

Booting the tablet into Debian, the first hurdle: touchscreen doesn’t work. The USB OTG works and I’m able to interface a mouse and a keyboard. So I have a complete desktop system with a 7″ screen, MALI-400 GPU and a 1.8 GHz dual core SoC.

Me: “So what you do?”

Him: “I’m a mechanical engineer. I work in aviations.”

Me: *thinking to myself* another fucking engineer. “Cool… I’m a R&D Engineer. How long have you been in Mumbai?”

Him: *thinking to himself* another fucking engineer. “Two and a half months approx.”

… *Some more random talk.*

Lesson/analysis 1: You just talk random shit to people. If someone is very chirpy and enthusiastic to present their perspective of things, clearly the person has had a social life and knows how to put their point across.

Lesson/analysis 2: Talking random shit is not hard. Well, its not easy either. There is this destitute homeless woman who walks the street just outside our quarters. The way she is living is not logical. I don’t really need to prove how its not logical but the guy had to prove why it is logical.

Me: “Why would someone live like that?! Its not logical!”

Him: “Whats not logical in it?”

Me: “She doesn’t have any plans. She doesn’t know what she will wake up to tomorrow. If you live linearly, you’ll always know whats gonna happen tomorrow!”

Him: *thinking to himself* This guy is so full of himself… dumb fuck. “but thats the point! she doesn’t know whats gonna happen tomorrow and therefore she is happy! She lives in the moment and doesn’t have any sense of right or wrong.”

Me: *thinking to myself* what kind of a dumb fuck would think this way? “Is that so? You can do that?”

Him: “yea obviously!” *you dumb fuck*.

What I meant to say was, if you have 2 hands, 2 legs, a brain and all of them working properly, you are not allowed to be… beggarly. If you have nothing to wake up to every morning, if you have nothing to drive you everyday, whats the point of living?

So opening up the terminal and firing a few of my default favorites:

root@debian:/# lsmod
Module            Size            Used by
sunxi_keyboard    2753              0
mali            159916              0
lcd               6964              0
disp           1046693              3 mali, lcd
nand            245773              2
root@debian:/#

Cool, Debian uses the “sunxi_keyboard” driver for OTG support. It doesn’t load a touchscreen driver. Although it ships with 2 pre-compiled modules (FT5x and GSLX680), the drivers are not loaded on boot (even after mod’ing /etc/modules). Conclusion, the touchscreen is NOT a Focal Tech or GSLX. Next wi-fi.

root@debian:/#lshw
bash: lshw: command not found
root@debian:/#lspci
bash: lspci: command not found

Fuck! But reading /var/log/messages, Linux does configure RTL8723BS wi-fi driver. `lsmod’ does not show it though. So lets mod /etc/modules… bingo! The driver loaded! But I need wi-fi tools (iwconfig and family). Since I cannot chroot into the tablet I’m at losfer words!

Lets see what else… reading /var/log/messages more closely, this is Debian Linaro 14.x or something (Linux Debian kernel 3.4.39). I even got the u-boot.

Me: “well yeah, you are not immature but there is some adolescence in you.”

Him: “I’m adolescent?! Tell me more!” *dude, you are the first shit who said that.*

Well… the guy rides to work on his cycle. I’m thinking of doing the same… its the best option. No fuel and traveling expenditure. But if the first thing that came to your mind was “I’m saving the environment by using a bicycle!” you are NOT immature, you are adolescent! Immaturity would have been like when one does not know how to listen to others.

Lesson/analysis 3: act normal. The person you are talking is another human being. Just like you are. They go to work, they have ideologies and principles that are NOT in sync with yours, they have had their share of troubles and you are not the only fuck in the world who has suffered!

Lesson/analysis 4: after reading this… don’t try and make an opinion of anyone. Its an exercise in vain. Your perception of a person maybe totally wrong or maybe so correct that it may hurt you and/or the person. Or even the person may not be at all what you analyzed. That would suck cuz then you’d have to question your ability of analysis!

I have written 1051 words. Fuck… that too on how to socialize. Geez…

May the force be with you,

Ninja.

A day in monotony

Standard

Hi again :). Its been a while since I wrote anything (yet again) but I was busy trying to be busy. Keeping yourself occupied when you really are anti-social and isolated (and loving it) is hard work. You have to force your mind to NOT to focus on the things that you lack or have a longing for. For instance, you earn enough to satiate all your whims but you are reticent because its not worth spending the money on it. No, not because you are a miser, but because you don’t have anyone to share the joy with. Sigh… am I not such an emotional fuck?!

Why am I isolated or why I prefer to be isolated is very simple indeed. I like it. I like the fact that my thoughts and my actions are not molded according to a group of individuals. I like the fact that I’m the master of what I say or do. I like the fact that if I screw up something, I have only myself to blame and if I achieve something, I have only myself to praise. I have only myself to hate and I have only myself to love. No complications because there are no variables in my life. And no, I’m not self-obsessed.

And although I like it, the monotony does get over the head. It does become boring being with yourself every freakin’ microsecond that passes by. Since I have no variables around me, it gets miserably monotonous. Get up in the morning, go to work, come back, go for a jog, eat and sleep. Nothing more, nothing less. On weekends, the only thing that changes is that I do not go to work. I go out and get lost in the urban jungle. It is the best part… and if you do fortuitously see me talking to myself with earphones on never giving a fuck about people around me, don’t worry, I’m getting expert advice about life. :D.

Its just, I’m irritated… I like my own company more than anyone else’s but there is nothing to do right now. Things are slow at work and there is no new development on the personal end either. The girl I wrote about is far away and frankly fading away. She was something good but I guess I must let her go now. Not because I want to, but because she is gorgeous and will get better options. At work, the R&D has come to a standstill, I fucked up the hardware. Fuck. At least that was something to look forward to daily!

Hmm… I just wanted to rant about something. I woke up today fed up (already and that too after having a good weekend) with the monotony. I’m working on updating the Linux Kernel Module Programming Guide to reflect changes in the kernel version 3.x. But its getting drier by the minute because I really don’t have anyone to discuss things with. I have the Internet Relay Chat but a real human is better than chatting with a person sitting at some other corner of the world.

The last few months were extremely happening. I got a new job, I made a friend (the girl I wrote the blog for), I switched to a new city and I had shit loads of research to do… happiness in short. Right now, I have a job (its no longer new), I lost her, research has reached a roadblock and I really don’t feel like exploring much because… well, I don’t get time. At least I have my poison to go through the night. I lost my music collection and with it died all the humanity. I have my guitar but due to lack of skills/knowledge that too is getting boring. Haaa… I know things will look up soon. I have much patience.

Sionara my good folks (lol… “good”.)

Ninja.

A text chat with my girl

Standard

ME: Good morning my precious! 😀 I hope you have a great day today… I love you loads!

sent: 08:30 AM.

HER: gm.

recvd: 10:30 AM.

ME: Hey gorgeous… ssup? 🙂

sent: 10:31 AM.

HER: nothin

recvd: 01:18 PM.

ME: So… I dreamed of you last night. You are so beautiful and I’m so lucky to have you… ❤ ❤ ❤

sent: 01:20 PM.

HER: hmm

recvd: 02:45 PM.

ME: Well never mind, I’m at work right now. I gotta make this jQuery script to geo-tag images… I wish I could have lunch with you, :-(. what are you up to my dearest?

sent: 02:50 PM.

HER: nothing

recvd: 04:38 PM.

ME: Wow… I just saw Angelina Jolie’s The Tourist… if I could just marry her!! 😀

sent: 04:42 PM.

HER: Go away then! I’m just wasting your time ain’t I?! you find everyone else more beautiful than me! I hate you!! You never care for me… you don’t even talk to me!! Go… I’m not gonna talk to you again! Find your Angelina Jolie and to hell with her!

Recvd: 04:43 PM.

ME: :-/

Sent: 04:44 PM.

X————————————X———————————–X

Random things that go on in that 2.5kG muscle inside my skull

Standard

15:25hrs IST: Sitting in the computer lab doing my time for the damned project lab. Sigh, cannot even play music on my MP3 player to ameliorate myself. The guy on my left is watching football news on some website… the speed is so freakin’ slow that the website is not even getting refreshed properly! I have no idea how Chelsea and/or Real Madrid is doing :(. Just made my reverse engineering tool but left it half way through, the debugger part is still left. I know I’ll do it in due course of time but right now, after achieving this feat, I’m infected with “WHAT NEXT?!” syndrome.
I wish She comes back early, I kinda miss her… too much. Not normal for a geek like me but yeah, I do. Never mind, the sun is shinig really bright and its hot! Damn the sun man! Comes up every freakin’ day glows like an idiot and then goes down. WTF?!
Ok so I’m playing Megadeth’s Angry Again quite well now, I’ll do that in the instrumental performance at the college fest. I need to go to that sordid HoD to get (read: plead f or) my letter of recommendation. Buckethead’s Soothsayer is so emollient, I listened to it 4 times already today. I’ve been listening to it for like 6-7 times perennially.
Everything is going down right now. Academics, mood… life. Hey! I just figured out why that Perl code for the Baum-Welch algorithm was not working! I guess I was referencing the array of hash incorrectly. I was getting mad at the Perl interpreter for demuring me… sorry Mr. Larry Wall :). Life is awesome! 😀 BTW, Creed is the most eclectic band I’ve ever heard. On one hand, One Last Breath is so romantic and on the other, Bullets kills all the romance… no I’m not castigating them, its just sway a bit too much. But nonetheless, I like Creed.
Dad says he has informers in college who keep him informed about my every step. I know who they might be, they just don’t know who they are conspiring against. Let them play, I already am a connoisseur of violence… they will be contrite after I deal with them. Geez! In-spite of core i3 processors in the lab, the systems are so slow! Damn, I forgot to bring the Debian image I had to write on the DVD. Never mind, I’ll do it later. I’m bored of writing now.
Its 15:30hrs now. The whole train of thought just took 5 mins… damn :/

Height of being bored

Standard

Well right now, I’m sitting in my room. After like 6 hours I’ll be still sitting in my room. After a few days or weeks or months, I’ll be sitting in my room. Just sitting and staring at the comp screen writing device drivers. Just sitting in my room and playing my guitar for 5hrs at a stretch. Sometimes an occasional knock on the door accompanied by humans asking if I have a freaking A4 size sheet. No incoming texts or calls, just occasional chats on facebook with some friend(s) and a few unknown humans.

No classes to attend. At least they kept my mind busy. I think I’ll loose my voice by lack of usage. Just keep looking at the four walls of the single seater room the whole day. It gets so boring and monotonous that even third grade Bollywood movies are also entertaining. The boredom is so tiring that most of the time I’m drowsy. One of my friends actually said that I looked like I had a full tankard of rum when he saw me in the morning.

Everything is so monotonous. The only thing that actually keeps me sane are my coding sessions which span from 6-7hrs usually. If that is not there, I’d loose my composure. Apart from that, everyday is exactly the same. The only thing that is different is Merlin. A new season that I’m watching, though from season 2 it has become monotonous. But 6 episodes back to back are a good deal against boredom.

The word count is 250 already and I’m drowsy. Its 1900hrs and I’m going to sleep (yet again), let the dinner go to hell. Even the dinner is same everyday, just sit alone at the corner table and try to eat the goo they call pulses. I’ve a long night ahead and things to do at night. Sio-freakin’-nara.

May the force be with you

Code_ninja