Tuesday, February 23, 2010

The VIM

:sp will split the Vim window horizontally. Can be written out entirely as :split .
:vsp will split the Vim window vertically. Can be written out as :vsplit .
Ctrl-w Ctrl-w moves between Vim viewports.
Ctrl-w j moves one viewport down.
Ctrl-w k moves one viewport up.
Ctrl-w h moves one viewport to the left.
Ctrl-w l moves one viewport to the right.
Ctrl-w = tells Vim to resize viewports to be of equal size.
Ctrl-w - reduce active viewport by one line.
Ctrl-w + increase active viewport by one line.
Ctrl-w q will close the active window.
Ctrl-w r will rotate windows to the right.
Ctrl-w R will rotate windows to the left.

Class Path !?


String myResource = .... ;
InputStream is = getClass().getResourceAsStream(myResource);
System.out.println (myResource + " is " +  (is==null?"not":"") + " on the classpath");

Thursday, February 18, 2010

Cook me up

This post tries to focus on the topic of Cooking or escaping in Web Applications.

The process of stripping/changing/modifying user input so that it avoids attacks like XSS is cooking. There are many ways to do it. One way is to strip off every input that the user provides. Let it be tags like <script> or <img> . The quotes are also removed so that javascript errors are avoided. 

The other way would be to take in what ever input the user provides and store it as it is in the database. The only place you would cook it would be in the UI. Escape/change what ever stuff you feel would cause your app to succumb to XSS and then display. This, I feel, is the right way to do it. 

Many applications that you see now may also have a JSON part to it. It might also be the case that the application is accessed by many other applications and these apps use the data. Not cooking this data is kinda buggy and cooking it defeats the purpose if this data is shown in a simple textarea. So I would rather let javascript cook this using the functions available.


update: The buzz has a problem with this. My blog title is  << Dinks >> and look how it came up in buzz .. 





The 18th again

I was a boring bday ! I remember the previous time when I got hit hard by friends who smeared me with chocolate cake and I was made to go to the temple. Nothing happened this bday and I got to understand that people change with time and distance. Thanks a bunch to Salih, Gayathri, Srinath, Gitesh, Swati, Shilpi and Sajith who called me up to convey their regards.

Thursday, February 4, 2010

Roamers

Coffee Shop. Its pretty bleak. People flow in, very less flow out. They like to enjoy but the coffee makers want them to get out after they have finished their coffee. That said they also look at the customer before they get into any argument.

Joy has just joined them. He is pretty good at talking to people. A real People Manager. Real d##k at heart but his kid like face makes up for the f##k up. He notices a table wasting their customer space by just ordering some black coffee. When a group comes into the shop asking if there were space, he proceeds to ask the seated to leave.

He walks through the rush like an ant and faces the person he feels is the most alpha.

Alpha (to the public): Screw those as...
Joy : Excuse me sir.
(This grabs the alpha's attention)
Joy : We have other customers coming in Sir. So we would appreciate if you could please let them enjoy their coffee as well.
Alpha (Looks at his with cool but menacing eyes) : Do you see me coming to your desk and telling you to get up coz there are better f##king unemployed guys who could do your job ?
(Joy is taken aback. Does not expect that sort of a response from a customer)
Alpha : Well ? Do ya punk ? (Takes up the Clint Eastwood face and laughs at Joy)
Joy : No.
Alpha One : Good. Dismissed !

Seems like Alpha is a movie buff. Clint first and then Jack ! Joy retreats very pissed.

Alpha : That would teach him a lesson.
Theta : That was not good of you. He works hard for money you know. He is frustrated and wants some thing for himself. Your insult must have depressed him.
Eta : Well he must have known that before he asked. We are here to enjoy ourselves and we pay to enjoy.
Theta : Imposing something that you think is correct is not validated by any action. We should at least order something else.
Gamma : Hmm .. Lets do that. Lets make him feel fresh again. Its said that a single action of kindness can do wonders.
Alpha : I dont have any problems with having a cup of coffee. But I dont agree to that saying at all.

Alpha turns and looks at Joy. Whistles him. Joy, unimpressed at this point of time, comes slowly.
Gamma : Hi, how are you ? Can we get another cup of coffee ?
Joy (Startled at this point of time, but regains his sense) : Yes, sure Sir.

Gamma (After Joy goes happily) : See. His face was glowing. Making a person feel better does make your day better !
Delta : Im not sure that that is true. How can making someone happy make you feel happy ?
Alpha : Suppose I give a beggar some money. The thought of what he would do with the money would make me feel UNCERTAIN.
Epsilion : To think about some thing like that makes me stressful. Takes a lot out of me. Its better not to think.
Theta : As the 'Bhagavat Geeta' says 'Do your duty, to the best of your abilities, for the Lord without any selfish motive, and remember God at all times - before starting a work, at the completion of a task, and while inactive'.
Beta : I cannot start saying how awesome was Bhagavat Geeta. I wish that was part of the curriculum. Not that there was anything wrong with the curriculum now.

Eta is thoughtful. Alpha does not like this. Alpha does not like anything much.

Coffee comes along with Joy. He places the coffee right in the middle of the table. Leaves.

Epsilon : Let me have some. It really soothes me. Just to have some hot coffee and to close my eyes.
Eta : A cigarette soothes you. Not coffee.
Theta : Coffee does not kill.
Gamma : Coffee does not burn either. (Chukles)

Alpha : The feeling that you get when you rest is unique. Its so fucking great. And thats why drinks excel.
Delta : I thought that was to escape from the problems.
Epsilon : I must have some.
Theta : Try some thing which you are sure would destroy your life ?
Epsilon : Destroying something that you think would go no better is the same as mercy killing.
Theta : So you support mercy killing ?
Gamma : I dont !
Beta : The whole world doesnt.

Its pretty noisy with all the traffic outside.

Alpha : If some one doesnt kill you, this noise will. Silence is just an illusion.
Eta : Killing for someone's sake is one thing, killing because the person is a burden is murder.
Gamma : Like that movie 'Kill Bill'. Never saw that much blood in one movie before that.
Theta : That movie promotes murder. Its no better than a live murder caught on tape.
Epsilon : With the kind of people around us, death might just come at any time.
Delta : Wonder what happens after death. I mean will we see all the things as we see here as ghosts ? Will we be reborn as insects. The same insects that we kill. Like a mosquito ? A bug which we think is insignificant ? Pretty confusing stuff !
Alpha : Who cares ? Live you Life now and dont think about something in the future.
Eta : But isnt thinking about the future the same stuff that make you live each day ?
Delta : Interesting perspective.
Beta : I agree to Alpha.

Joy comes up to the table. He is all happy and stuff.
Joy : I shall I get you the bill Sir ?
Gamma : Yes, please.

Alpha (after Joy left) : What a f##k up. Just happy because Gamma was nice to him. Thats as nasty as it gets. He really has problems. He cares for what we think ! Hah!
Theta : The thought of helping a person does a whole lot of good.
Eta : Good is perspective specific.
Gamma : Good is something that make a person fresh.
Delta : So we could categorize killing a person suffering from a malicious disease that is mercy killing, good as we are helping him suffer less.
Beta : A valid point.
Theta : I would suppose thats why in some countries its legal. But I dont approve.
Alpha : I thought we dropped this topic long back. It really pisses me off.

Joy comes with the bill.

Alpha (looks at the bill, takes some money from his pocket, throws it on the table) : Keep the change.

Joy, confused, takes the money and moves away.

Melvin gets up. Walks, opens the door and enters the world again.

Wow Bash


bash:~$ ping yahoo.com
PING yahoo.com ...

bash:~$ ^.com^.co.in^
ping yahoo.co.in
PING yahoo.co.in ...