Powershell – Getting the heck of it

July 13, 2009

Linux! Shell ! these are probably the most uttered words in any tech discussion. I admit that i like linux a bit and a frequent visitor of the desktop screen of ubuntu in my dual boot setting. Its true that you can pretty much “operate” linux from its shell and Microsoft’s equivalent to it (or atleast thats what it seem like)  is the Powershell utility. I wouldn’t consider it as omnipotent as Linux’s shell but it managed to kindle my curiosity

This was my first useful powershell command:

gci -r | where {$_.name -eq "target" } | rm -recurse

looks similar?? This script searches from current working directory recursively and removes all the “target” directory. In case you haven’t guessed it the above command is ps substitute for `mvn clean`. Unlike linux shell commands the output of each powershell command is not restricted to a text stream but rather a object stream that can be processed by subsequently piped commands.

Some commands you might find useful,

1. ‘gm’ that lets you reflect on the properties of the passed powershell object

2. ‘Sort’ – sorts the powershell objects based on property. For example if you want to view the processes in decreasing order of the PagedMemorySize, you need to key in,

ps | sort –des PagedMemorySize

3. saps / Start-Process – starts a new process.

Note: Each elaborate powershell command has a nifty alias that is easier to type .  Command that lists the alias – command pairs,

Get-Alias | select Name,ResolvedCommandName | more


Groovy – Operator overloading

July 1, 2009

Yeah. this is one of the things that promotes a language from “ah ! I use it”  into “ah ! Look what I can do!” Among other cool things to groovy up your work, operator overloading is an absolute must know if you plan to fascinate yourself (and of course your PM) . Cutting to the chase here is the sample code

class Money{
    int amount;
    String currency;
    Money plus(Money m){
        return new Money(amount:(m.amount+amount),currency:currency)
    }
}
Money m= (new Money(amount:1)+new Money(amount:2))
println m.amount

 

Ok. unfortunately groovy doesn’t support specifying operator character in method signature and this stems from the limitation from java [ groovy has its roots at the jvm ]. The example above may not provoke more than mere “thats cool” but implications of this can be seen in GDK (groovy dev kit) with includes some extensions for java libraries. So when you say,

list=new ArrayList()
list<<1  // adds the element to the list

here the operator << corresponds to the leftShift method being overloaded in the arrayList . This is groovy’s style of saying   “ list.add(1) where List should have Integer generics” as you say in java. Yes you guessed right :  “autoboxing” is something groovy provides out of the box.

Not yet groovy? Combine the operator overloading with the use construct.

class FakeAdder{
    static Object plus(Integer a,Integer b){
        return a*b   //this is not a bug!!
    }
}
use(FakeAdder){
    println 2+5
}

Output: 10

The operator + has been overloaded in the specific context to multiply numbers rather that standard add. Very powerful indeed. Try it yourself and share your comments.


Terminator salvation

June 28, 2009

If you are listening to this then you are the resistance

This is John corner’s words as he addresses the resistance groups over the air. The human race fights the mighty “skynet” which is relentless in wiping out resistance. John corner leads the resistance army against skynet . Both sides are equally mighty but there is one difference that brings victory to humans even though skynet tried to exploit it ..only to fail.

I am not going to spoil the fun you get from watching in the theatre. I have no words to describe the action sequences. In the second scene of the movie the camera is literally placed in the helicopter that is shot down as soon as it takes off with John Corner driving it. This was the best action sequence i have ever seen and i am sure you will enjoy every meticulously planned and executed stunt sequence. So what are you waiting for!?


Get in the Groove.. Groovy Style

June 27, 2009

Groovy . besides the funky name is a really cool dynamic scripting language to learn. Let me ask you a question: Do you key in all your code in java ? if you answer ‘yes’ then you are 50% groovy expert already. otherwise, well its never too late to be productive. If you are like me coding  in java and following the ancient write –> compile –> execute cycle over and over again until you see what you want / your PM wanted . Then you walk proudly across the office corridor to the PM’s room and say : “This is what i was working on this week/month/year and there you go”.  This is a usual routine in software development. The sooner you can bring the smile on your manager’s face the sooner you will be appreciated. With groovy you can bring it on in hours/ days.

As much as i like java and appreciate its realization of OO concepts deep down there are things I hate in java. If you are thinking & coding in java 24×7 chances are, you will stumble upon those annoying things soon. One such annoyance: clashing of class names imported from different packages say java.util.List and java.awt.List . You may end up prefixing one of the class usage with package path. Welcome to groovy world. Here you will find that you can do something like,

import java.util.List as UtilList
import java.awt.List as AwtList
UtilList list=new ArrayList ()                                                                             
list<<1

Surprise,surprise this code actually runs if you run groovyc or groovy on the file (although it might output empty []). I am going to miss my late friend : “ public static void main“ .

If you are a python  programmer you may not be impressed by the above but guess what : your language doesn’t run on a JVM and embed with java code without compromising  performance greatly and don’t even get me started on Jython.

Surprisingly you will notice that your code can be compiled to a corresponding java class file [ jad classFile   - to see the generated file ]. from that point on jvm sees everything as class. This gives enormous edge for groovy over other dynamic languages because undeniably a significant number of organizations use java for developing their products. You may not regret spending weekend learning groovy. I am sure most of the things you learn in groovy ( be it currying, meta programming ) will make you cry “ duh!! wish i had known this before” . Have fun groovying around :)


Copying is Not an art

October 16, 2008

When was the last time you got caught copying..? Once in our lives knowingly or unknowingly we tend to copy others. Copying is a creativity killer in places like music industry . Copy cat music directors have to be put to shame before law and people. Recently i heard a copy cat song – “unakena naan..”  by vijay antony in kadhalil vizhundhen tamil movie that made my blood boil like lava. These are exactly the kind of things that keep me away from listening to tamil music. Lack of orginality and greed to get famous drives such artists to fame. Should we allow them.? is in our hands!

Imagine a lazy student and a brilliant one appearing at an exam. The brilliant guy just thinks creatively to answer the questions but the dumb guy peaks at the brilliant guy’s answer and writes down all the answers when the inviligilator comes back after a coffee he looks at the dumb guy’s paper first and gets impressed. If the tamil music lovers want to “see” music and shell themselves from the rest of the world.. well… thats all that can be done. Anyone can play existing music and plugin their own lyrics but it takes creativity and innovation that makes a music director . If vijay antony can’t deliver that.. he is probably not fit to be one..

This blog may sound outragious but the last thing i want is one crack MD copying a song i love and make it sound even worse… Someone should put him out of his misery please.!!


Big Bazaar in chennai

October 2, 2008

I know what you are wondering. I have some obsession with “Bazaar”. Well, i agree! My parents had already been to big bazaar and were kindling my curiosity by talking about it all the time. Cheap and best they said.. Well, i decided to put that to the test. On a national holiday one would typically expect chennai to be awake at 6 pm. To my  surprise traffic was flowing smooth , speaking of luck !! We were worried about parking frency in TNagar and decided to park in a place away from our target shopping mall – BigBazaar. After commuting for precisely 8 mins we hit the spot. Crowded?? I wouldn’t exagerrate but to be frank it was not the worst as expected. As soon as we stepped into the mall we found an empty food place not by the measure of people but the measure of food itself. I was hungry and starving for an evening snack and was disappointed to see empty plates :( Time to move on .. I consolidated myself.

The first floor was mostly for men with an entire collection of items like shoes, jeans, t-shirts. When I stepped in i noticed the poor organization of things. I could find shoes unpaired and messed up by a constantly moving cloud of people. There were very few people to care about selling stuff and they would constantly make shunts across the way to ask people what they wanted. I wanted to purchase a pair of shoes myself : approached a guy and told him my size. He made a quick jolt to the “stock place” and brought a new pair of them. Man!! that was fast. But next hurdle was to try them on. I looked around and to my surprise noticed that there was no bench to sit on and try my new shoes. Just put my feet on some shoe boxes that lay in the corner and tried it. It fit me perfectly and made my choice to go for it. There were 60%.. 50%.. 40% Discount boards jingling all over the place and my deal was pretty cheap… a class 1 reebok shoe with 40% reduction. I was never “happier”.

I juggled my way through the crowd only to find things getting messier. The people in charge of billing were either too slow or couldn’t take on a crowd. There were around 4 counters and things moved veeeeeery slowly. After waiting patiently for over 10 mins eventhough i was the second guy I was relieved to see my new shoes getting packed and presented. That was a nice but mixed experience.  We hit the second floor which had girl stuff – chudidhar, jeans and “stuff” . time to move on :) Third floor was packed with travel bags, bed spreads, gift articles ,kitchen items etc. We spent some considerable amount of item just glancing over the price tags just to find thing a bit above our normal budgetting standards. Despite that we made some quick picks like bed spread and pillow covers.

In the fourth floor everything was wonderfully showcased. We found dinner furnitures neatly arranged in row by row fashion. They looked cool. There was a separate section for electronic items like TV / Washing machines and owens. We didn’t spent much time there except in small section were there were some interesting books of syndney shelton and ripley’s believe it or not.. made some purchases there and made the four floor descent but i must say that we restrained our self from all the distracting offers and focused on climbing down the stairs :) The exit had a surprise…. We had to produce all the bills to a security guy. We frantically pulled out all our purses and put together 5 to 6 separate bills and gave it to the guy who then neatly stappled it and returned back! that was it. Out of BigBazaar.

It was nice to make a quick visit and write about big bazaar. Overall I was satisfied with the rates. Things were affordable but they desparately needed a time off to clean things up. If you are a quality freak i would say you have no business here. Do not expect people to care too much about the customers. Big Bazaar is better in terms of pricing and thats all it is. Quick purchases were not possible because of big queues. You can’t be fussy about choosing things because you will not be asked twice. If you plan to visit this place any time in the future.. good luck and happy shopping :)


Life at Bankbazaar

September 18, 2008

College life is over but never too late to say… “hurrrah!!”. Thought i will update you all on my life status after a long time at BankBazaar.com ( 3 months to be precise). I joined this startup company after some pretty serious thought, though i don’t do that often :P  Anyway, my life took a sudden diversion into the “road not taken” and here I am, enjoying my ride. There are a couple of things about this company that impress me most: A diligent and smart development team that comprises of people from top notch companies. Believe me they know how to work through problems.

A startup culture is certainly different and unique in its own way. I believe not all startups are the same but there a few basic things that i find common to all startups. The team is usually small and close knit. You can always walk up to your colleague and talk freely. But, don’t expect extravagent facilities and comforts. The developers usually work in small workspace and use available comforts to the fullest. It is in a startup that people will learn to manage time, space and money in the most efficient way. There is almost always no time to fool around.

Till college i have been thought to follow a narrow path that is tightly bound by theory that some nut has written in his boredom. Life is lot different than following some text. One thing that has struck me most in bankbazaar is that there is plenty of work around and there is always more than one way of doing it. Smarter you think better and faster your work will be. This is what i call positive stress. Whatever be it I am simply enjoying it.

thanks for glancing by.

Nishant


ICPC experience

September 9, 2008

Dated:November 2007 

Recently, I made a one week visit to IIT kanpur to participate in the south asian regionals ACM ICPC(International Collegiate Programming Contest) . Land of diversity,  well, I never knew what it meant until I made this epic 3 days journey to kanpur, by train ofcourse. Did I expect to win or be the champion or bow to the grand accolade? No.. Not at all. It was simply not for me :) I was there to enjoy the change and I was never disappointed.  Just thinking about the fact that I was there amongst the greatest and the brightest of programmers in India gives me goose-flesh.  
If you aren’t already familiar with ICPC: its a contest where greatest of the programming community are challenged with tricky algorithmically-solvable problems. We can spend five hours to solve them all and guess what- we cracked 5 out of 7 and placed 13th , I know – its prime :)  Check out the results in the ACM site. My coding practise in topcoder and mipt was definitely helpful in getting through some of the tricky problems . But we were hopeless struck in a maximum bipartite matching problem. The most painful part is that I could easily code the algo in a few minutes but it was the resolution into a standard algo problem that took the life out of us. Well, its the story with most of the problems. You never know what clues lay buried and what trap the problem setter has in store for you. Its all part of the fun and I have no trouble enjoying it! 

Some day I plan to write a post about my brief but busy days with “contest-programming” during my college days. To me it was like riding a ferrari on a bumpless road: Exciting and mind-blowing at the same time. Coming back to my experience at IITK, the campus atmosphere was simply fantastic and students were like party animals: It was enjoyable eventhough its an understatement. The train journey was a little painful but we managed to survive long enough, to reach our homes. Now, I can easily spend 15 mins just thinking about the experience and smiling it to myself. Hope you enjoyed reading this blog.  Check back for more on my sweetest experiences in life…. Thanks for glancing by.


My Nokia E51

August 17, 2008

Nokia E51 has been around for a while now. I had a chance to buy one for myself. The mobile is a marvel. Everything you expect out of 11G is perfectly packed into that sleek looking thing. Some of the things i like about this mobile,

1) Wi-Fi enabled : I have wifi at home and office and these are the pretty much the places where you will find me at any point of time except ofcourse the travelling time. My Nokia E51 seemlessly connects to the available WLAN and the applications have no problem switching instantly.

2)Push Mail : When at work i want to work as fast and effectively as possible without having to look-up mails and messages constantly. My E51 notifies me about  new “important” mails with a beep and sits quietly in a corner until i pick “her” up and read the mails. It has a decent built in voice synthesizer . I am yet to figure out the settings that will make it read out the mail .

3)Media : 2Mp camera, visual radio, decent mp3 playback , voice recorder. E51 is packed with all these stuff. Imagine taking a picture when you are listening to the radio and posting it to you picasa album all in one device.Cool huh!?

4)Simple navigation  : My E51 came with S60 mobile OS. The navigation is like a breeze . I am not a great fan of touch screen so i don’t regret much. Besides, the keys in E51 are well aligned,neatly placed and almost flat . I have no trouble churning out my emails and messages using the keypad.

5)Sync up with PC: E51 comes with Edge technology that allows you to browse the internet over your voice service. You just have to activate the plan which could cost you on a per month basis. The PC suite that came in a cd has all the sync options i needed including,

  • convert and sync audio instantly
  • image sync
  • contacts and
  • calendar and most importantly,
  • application installer

6)Cool applications : If you are owner of E51 you will typically end up browsing through a whole collection of applications each one of which promises to make life easier for you. I found applications like frings (mobile messenger thats like pidgin in linux) and touchticker ( that reads rss feeds from the internet and churns out news snippets). The installation is made very simple via the PC suite.

These are some of the cool stuff i found so far though i am constantly experimenting . I will keep you all posted. Thanks for passing by.

Nishant.


For a Topcoder

March 5, 2008

This article is for those who have registered in topcoder and wondering “what next?”.
Well, the obvious answer is “just do it” :) Start participating in srms regularly and get into the groove.
1)Try your best to attend matches.
2)Make it a point to just practise in a couple of practise rooms before taking on an srm. It helps you in getting warmed up for the match.
3)Chill and switch!! I have seen many (including me)coders just knocking their heads over the wall for simple 250 point problems during my early days of topcoding.Trust me, it never helps.!! If you struggle with div2 250 pointer for more than 15 mins its probably better to switch to 500/1000. This is very important tip.
4)Hang on till the last minute.When you are done solving the problems which you thought were right, just have a second look at them. Just do a exhaustive testing of your solutions with varied input cases. It helps in 2 ways
1) Helps you figure out a mistake in your code. A resubmission of a correct solution is always better than a first submit of a wrong one.
2) Helps you prepare yourself for the challenge phase. A tricky test case can act as a killer in the challenge phase blowing off all the solutions! I have personal experience of that one!!;)

This should keep you up for while in the ratings stack. But trust me, PRACTISE MAKES THINGS PERFECT!! This is very much true when it comes to topcoder.
Cheers and happy coding.