Sunday, August 15, 2010

Time's up !

Leaving for Yale tomorrow.

I started packing _today_.

I think I'm finished - which is not really an encouraging statement because I thought I had finished packing many times today.

My mother's sending lots of ready-to-eat food.. the customs people will probably think I'm trying to open a restaurant or something..

Wish me Luck ! (well, with 91CR on my side, luck is my lady.. hehe..)

Thursday, August 05, 2010

Convert a character to hex using javascript

There are lots of massive solutions to this - here's a 0.2 second solution ( I am posting this because I saw this )

"x.charCodeAt(0).toString(16).toUpperCase()" is the hex of x. Use charCodeAt(i) for a full string (parseInt otherwise).

I realize that this is trivial. It is stupid. It can be done in many ways, most of which are ridiculously easy.

Unfortunately, people are failing to do even this. Meh, more proof for the FizzBuzz statistic.

Friday, July 30, 2010

The margin-top problem (and solution !)

This is one of the more irritating CSS errors* around - you put something inside a div - and the div takes on the margin-top of its child element.

(*This isn't really an error - it's technically the correct behaviour, but not what a programmer would expect.)

To illustrate - here's a page with multiple divs, with margin-top:0px specifically assigned for the divs.

The page looks like this : [link to page]
The margin-top problem


It should actually look like this : [link to page]
Solved margin-top


Here's an example of the CSS used:

body {
 margin:0;padding:0;text-align:center;background:#222;
 font-family:"Times New Roman", Times, serif;font-size:16px;
}

#box1,.other {
 width:1000px;
 margin:0px auto;
 background:#EEE;
 border-bottom:2px red solid;
}

#box1 {
 height:270px;
 margin-top:0px;
}

.other {
 height:150px;
 margin-top:0px!important;/*makes no difference*/
}


And some of the HTML :
<div id="box1">
 <h1>This h1 tag should have a margin-top. Instead, the div gets it.</h1>
</div>

<div class="other">
 <p style="margin-top:50px;">Text in a styled p tag with a margin-top : again, the parent div takes it.</p>
</div>


To solve this problem, just add a padding-top:1px or a border - any padding or border affecting the top of the parent element will resolve the issue.

As you can see, chrome has this problem. I have tested it on FF, Opera and IE8 with the exact same results.

Tuesday, July 27, 2010

Dead Code Olympics : Part 1 - Internet Explorer 6

The web has come a long way since the time of spacing gifs and tables inside tables inside tables (repeat ad nauseam) - however, a great many developers and users have not.

I'm going to list one of the most irksome practices of these curious creatures:

Internet Explorer 6

IE6 ! Gadzooks, forsooth ! Quite possibly the biggest burden on the internet right now. IE6 was provided for free with WinXP, and has cost developers and designers a fortune in antidepressants.

IE6 can change HTML when CSS is changed.. don't believe it ? See this :

In Chrome
In Internet Explorer 6
Notice the arrow ? Now, (Bruce Lee style) look at what its pointing to. "ct" ?? What's that ?

Well, "c" and "t" are the last two letters of "contact" - IE6 is simply repeating the end of the previous line.
If you hover over "ct", you get a hover effect on "contact".

However, you can stop this from happening - just change the width of the parent div, or the border, and the effect goes away.

Such is the power of IE6.

Kneel. Or you will be knelt.

- Debayan Gupta

Saturday, July 24, 2010

Getting ready to move..

Spent the last few weeks finishing up all my projects (my backlog is always twice of what it should be).

Over the last two days I had to deal with no less than four FizzBuzz-challenged "developers" who mucked up my carefully optimized code by "removing obviously unnecessary lines" - I nearly ended their obviously unnecessary lives before my brain kicked in - at which point I simply decided to charge extra.

It really is rather sad to see the sheer number of programmers who, simply put, cannot code. This problem is compounded by the fact that most of these people are under the impression that they are experts.

Pooh.

Wednesday, April 21, 2010

I sense a Censor

Censorship: It tends to get irritating very, very quickly.

Indian censors really take the cake - they replace "hell" with "heck" in the subtitles. Which works in most movies, but not something like "Bedazzled".

"Paragraph one states that I, the Devil, a not-for-profit cooperation, with offices in Purgatory, heck, and Los Angeles, will give you seven wishes to use as you see fit"

What the heck ?

Not only do they get stuff wrong all the time (it really is quite obvious that the people writing the subtitles have no knowledge of English), but I mean seriously ! Censoring SUBTITLES ?!! (and mixing up "lichen" and "lycan" )

They're been cutting out crucial scenes from movies for a long time (anything "too gory" or "showing too much skin") - but allowing shows like Splitsvilla to continue - which do you think is worse for our innocent, naive little minds ?

And you know what ? This is helping increase piracy. I watched this movie a couple of months ago - and I liked it, but it seemed that some scenes were cut off (there was an obvious break in continuity), so I went and bought a DVD. Guess what - that was censored too.

So I ended up having to download the bloody thing, just to watch the whole movie. Which I PAID for. And it wasn't a sex scene. It wasn't very gory (I've seen stuff a lot worse on TV). And it certainly should not have been censored.

So just for the heck of it, I decided to find out how many people ended up downloading/ buying from pirates even after they had bought the DVDs, or had decided not to buy originals because they would be incomplete.

I asked 16 of my friends - here are the results :
2 - usually buy
3 - always download because its cheaper, and easier to get.
11 - download pirated stuff because its better.

And guess why its better ? 
  1. They're compressed to 700MB or so (not everyone wants to get a hi-def - they'd rather watch the movie first, see if they like it, and then maybe get a better resolution)
  2. They're out first - movies are often released much, much later in India, so people who really, really, want to watch, people who can and will pay, people who are anxious for the film - will download a hall cam record.
  3. They are complete ( Indian censors substituted "courtesan" for "whore" throughout the movie Original Sin - which is pretty funny, especially in places like "you liar ! Thief ! Courtesan !" )
But that's all right. We don't need FTV to spoil our minds. Or bad language (most parents would be quite.. surprised to know how many swearwords their children are aware of). Or words like "hell".

May you burn in heck.

Saturday, April 17, 2010

How to survive interviews

My aunt came over to my house today, and I was subjected to over an hour of learned monologue (with my aunt, its always a monologue..). I had spent most of the time thinking about Elin Nordegren the Floyd-Warshall algorithm, but I noticed an ant on my wrist, and was startled into listening for over ten seconds.

Apparently, her daughter's college is having mock job interviews (conducted by their placement cell). They are to

  • wear ironed clothing
  • shave
  • shun jeans
  • wear pleated pants
  • (girls) wear salwaar suits
  • hold their noses up at a constant 30 degrees
  • act in a manner expected of a dapper 70 year old Englishman in the 1830's
  • generally, be a cowardly *&^$ with a bad attitude.
It is quite evident why these particular imbeciles are stuck with jobs at college placement cells (bad ones at that !) - they have no idea whatsoever of how to give an interview. ( and no, dear residents of America, its not "inner-view" )

An interview is your chance to give your employer a glimpse into the best of you. The best of you. Doing the same, stupid thing as the other four hundred candidates (who have all been to the same career counselling classes as you ) is not going to help.

A good haircut ? A good idea, especially if you're a hairdresser. But it is certainly not the main thing.

Ridiculously expensive clothes ? Again, missing the point.

Surprise surprise, there is no magic formula. No really, act surprised. Because there are lots of "institutes" which provide "personal interview consultancy services". And they earn a lot of money.

The only real way to give a good interview is, as clichéd as it sounds, is to be yourself. You would be surprised at the number of people who cannot do just that.

Most people are merely following the herd, with no idea of what they really want to do. They have no real plans for the future - this is not to say that they are not capable of intelligence. That is what's really sad - these people possess the capacity for thought, but are unable to utilize it because of a variety of reasons.

Can you think ? Would you get punched by Bruce Lee for looking at his finger instead of the Moon ?

What are you good at ? Can you lead a team ? Do you want to ?

Make sure you have the drive, the ambition, and the _power_ (for the lack of a better word) for it to make sense for them to hire you. You should add value to their organisation.

Remember - you are giving this interview to get into a job, where you will be expected to perform, and perform in a way that will do justice to the expectations that you have raised during your interview. Are you ready to do that ?

Be honest. Be intelligent. Know what you want.
Don't waste their - and what is infinitely worse - your time.



PS. I know where the extra "is" is. I put it there.