Friday 21 June 2013

Happy Birthday Stack Overflow!!

Today is Stack Overflow's 5th birthday. You know stack overflow,  the most amazing and useful resource for programmers both noobs and experienced alike. Stack Overflow was started by Jeff Atwood and Joel Spolsky in 2008. Among the crowd of forums which more than often were filled with spam or irrelevant answers, that had no mechanism to highlight the best answers, SO came as breadth of fresh air for programmers who were looking for relevant information or lets just say Answers!!

Here you can find the post where Jeff Atwood announced Stack overflow.

Quoting Jeff Atwood:


Stackoverflow is sort of like the anti-experts-exchange (minus the nausea-inducing sleaze and quasi-legal search engine gaming) meets wikipedia meets programming reddit. It is by programmers, for programmers, with the ultimate intent of collectively increasing the sum total of good programming knowledge in the world. No matter what programming language you use, or what operating system you call home. Better programming is our goal.

Although its been only 11 months since I joined stackoverflow, it has become my hobby to check daily for questions. My rep is nothing to brag about, but its not the rep that keeps one going, is it? As a programmer we are always looking to get more information and SO offers real world solutions for real world problems and not just ways to hack code and make things work. Not only this SO and Programmers SE offers us an opportunity to do some general chit-chat also :).

Stackoverflow has more than 5.2m(illion) questions. Programmers, Superuser and Server Fault have more than 357K questions.

Another positive positive that came from stackoverflow's success is that Jeff & Joel did not stop with SO, they created Stack Exchange network, which consist of more than 100 websites, ranging from programming to cooking to lifestyle, making information on internet more accessible.

Some people argue that SO made us lazy and we have stopped reading books and going into depth of what we do, but there are many instances where people went against spoon feeding and redirected the OP to the docs and if still she/he had any doubts, they even explained what it meant.

Yes, I am a fan of SO. It has made me a better programmer, lots better.

So here is to the most amazing & useful site on the net. It has been 5 years & many more to go.

Saturday 15 June 2013

Fixed Table Headers

Persistent table headers our more notorious than one might think. A simple position:fixed on the first row won't do the trick. Now you might ask, why another tutorial on how to fix table headers, when there are many existing solutions.

What I needed to do was a bit different. It was table inside an enterprise web-application, and every column had been allotted different widths, many of the existing CSS/JS solutions required knowing the width of the table before hand to work. So I had to cook up something else.

Position Fixed on Table Header

Whenever we are faced with a situation where we have to make a fixed table header, we first think about fixed positioning. Well this is what happens when we have fixed positioning.


 So, What's the solution?

I observed that if every cell of row had a defined width, It would not collapse like above. But as I said, dynamic tables were not helping. So I created some JavaScript(it uses jQuery too) to give every cell in the first row a width of the corresponding cell in the second row. Here is the code.


Yup that's it. 16 lines of JavaScript to the rescue. The only "Magic" happening here is the 'spacer' row, which    keeps the house in order. As we know that fixed positioning takes the element out of the flow of the DOM, spacer ensures that the second row does not slip below the first.

Any advantages?

There are many advantages IMO, here they are:

  • No fixed width! it does not limit you to have a fixed width on your table, or know it before hand.
  • Runs once. There are solutions that re-position the header every time it slips out of the view.
Tested on Chrome, Firefox IE 9.
Not on mobiles
That's it. Share your views..

Friday 17 May 2013

Finding the Real Programmer

A question or shall I say, a quest to find the Real Programmer has gone in vain so far. Yes, a real programmer, the one we hear stories about. I too like any budding programmer turned too the most powerful tool at my disposal, Google. After searching for quite some time I have drawn my conclusions which I want to share with you.

I have made a small test that helps you determine whether you are a real programmer (or not).  So are you ready to face the moment of truth. There are two question you have to answer and be truthful about.

Question 1: Do you breathe? Can you touch yourself ? Can others see you ?
Question 2: Can you code? Forget how you code or what you use?

If the question to the first question is yes, then it's safe to say you are Real. If second answer is yes, then you are programmer, to sum it up you are a Real Programmer.

So, why this eternal debate? I assume that it has got to something with our quest to get better at programming. I don't understand when people say:


Real Programmers use emacs/vim, while idiots or fake one's use IDE's


I say to hell with it. Aren't we, as programmers supposed to use things that make our life easier and us more efficient? Surely, earlier IDE's  may not have been good enough to satisfy the programmers at that time. But that doesn't mean that today people who use IDE's are idiots who can't do things by themselves. Don't think whats cool work with what makes you more efficient. If you can code better in IDE's that's fine, if you are amazing with the emacs/vim/notepad be my guest. But both parties should put down their swords down and work towards progressive code and better software.

This question at Programmers S.E. made me laugh, but after going through some answers/comments I felt that we are still very caught in the Real/ Unreal things that Real things that matter may get left behind. IMO we should not be categorized by what tools we use, programmers may be categorized by their experience and knowledge. It's amazing that you can debug code by scanning the code, but even if you have to fire up a debugger, you don't have to sink in shame.
These tools are made for you and by programmer's. If it were a bad thing it would not have been done in the first place.

For me a good programmer is one who remembers that first, we have to solve problems and code is just a tool for that.

Similarly another debate I fail to understand is the one of Windows vs. Linux vs. Mac. When you head over to The Verge's forums, you are sure to find apple fanboys going to microsoft tribe to post a rant or vice-versa, this is less of an issue specific to programmers but it doesn't mean that we are untouched by this trend. When it comes to frameworks we are always at war against other language/frameworks. Every discussion on the frameworks has a comment like X sucks Y rules.

I think that this war will not make us better programmer. As for being Real, the real programmer does not care about Windows/Linux/Mac more than he cares about the problem at hand.


Monday 6 May 2013

Jeff Atwood, Joel Spolsky, Thanks for Stack Overflow!

If you code regularly chances are you might have stumbled upon Stack Overflow, a Q/A site for passionate programmers where they answer questions and get answers to their problems.




Via this post I would like to thank Jeff and Joel, the founders of Stack Overflow for this wonderful gift to the internet.

I have no qualms in saying that the two sites that make me a better programmer are Coding Horror and Stack Overflow.

When I started programming, things outside the textbooks used to excite me more. But the walled garden that Indian Education is has little room to accommodate such people, in such times I came across Stack Overflow and I was surprised by two things

  1. Show Respect-Get Respect  :  The place I come form in India, people don't show respect to unknown people face to face, let alone the internet. But here I was seeing people showing respect not only to those who gave answers but also to those who asked questions (although If your questions is like "X framework vs Y which is better, chances are you will get a good load of people closing your question).
  2. Advice, not just answers: There are two ways doing things,  one is getting them done anyhow and the other is getting them done correctly. At Stack Overflow, people not just take time to solve your problem, they also advice you on how things could be done better. Of course if you want an instant hack to solve the problem, you get it, but the person who gave you that hack might just leave a note like:-
Hey this is just a hack, if you want that you not face problem in the future do this:
             function foo(){
                       //correct code here
             }

That's something that commands respect.

Another thing worth mentioning is the community moderators. They actually take time out of their schedules to keep their favorite site free of span by closing questions that violate the guidelines or are too broad to have a specific answer.

Jeff, Joel and their team at Stack Overflow has successfully devised an online discussion system that brings out the best answers and keeps the spam to the minimum.

Stack Overflow has now expanded to Stack Exchange, a group of 90 Q/A websites ranging from coding to cooking, from game development to science fiction and photography and bicycles to physics. Making internet a better place.

Having said that, its not necessary that you have to ask to be at Stack Overflow, if you are one those people who can solve pretty much anything by themselves there are several stupid, question-asking, solution-hungry programmers like me who would love to hear from you.

Here are a few big guns on SO


And of course we all are famous in some circle, aren't we ? :)

Monday 29 April 2013

Lessons from Shipping

We are developers..that's not the breaking news. According to Marc Andressen :
 "Software is eating the world" ,
 and as developers we are fueling the Frankenstein's monster. Everyone develops for a different set of audience. Some people develop for developers (think API's, IDE's) . Some develop for "clients". But for once everyone should try to ship an app for those who are not like you (developers) and those who don't give you any configurations (clients). Develop for those, about whom you don't know a thing. There may be people who feel that black backgrounds look good, while there may those for whom black backgrounds suck! What are you gonna do in such a situation.

"CODE FOR YOUR GRANDMOTHER"

Yeah that's right.

Lesson No.1: Think of the user as a complete newbie to computer who has been made to sit in front of Linux terminal and asked to do a git rebase. In my experience, my app totally sucked at user experience when I gave to some people to test it. It's help commands were not good enough, my app was not responding the way they wanted them to. 

"DON'T ALTER THEIR NORMAL BEHAVIOR, ALTER YOUR CODE "


Lesson 2: User's are very lazy when they have to learn something new (after all computer make life easy!). eg.: When an action has to be completed the user is accustomed to hit enter. You should include this as a part of the code. Don't expect the user to change such normal actions.
Lets take another example,
Windows 8, what's the biggest complaint you hear about it (before continuing, This is being written on Windows 8). Most people don't like being pushed in and out of metro. Like if you open a music file on the good old desktop, you are catapulted into the metro world, Full screen with no hyphen,square & cross to do stuff with it. They are completely bedazzled.

"READ THE GUI GUIDELINES "

This is one thing that most designers may take lightly, unintentionally or intentionally to make their app stand out. But this is a huge mistake. Let's not forget that these guidelines are created after much usability testing and research. It's not that one should not be innovative. But following guidelines is required to maintain consistency which in turn will prevent the user from feeling that he has been sent to Mars.

And in the end one more thing

"Design Dumb, Code Smart"

Here are some links to help you design better



Introducing FlexMailer

If you are a web developer, chances are that you may have written a PHP mail script, either for your own site or for your client. PHP is baked in with Apache, which makes it the most widely used scripting language. The success of Wordpress as CMS is largely because of ease of setup. It's no secret that wordpress is written in PHP.

All right coming back to php. PHP has a built in mail() function that enables websites to email data through the server, instead of the traditional mailto method. This has empowered web developers to include a mail form in their websites, which leads to better UX.
A php mail script usually looks like this

As you can see that for every field you add in HTML form it has to referenced in the PHP script. This is a tedious task to do and every time you work on a new form, you have to rewrite the whole script.
As a solution I have developed a script in jQuery/PHP which automates the entire tasks by automatically retrieving the names and their values. You can find FlexMailer here .

Below is a basic code that shows how you can customize FlexMailer.

Add this script to your HTML.(Load jQuery first)

Now in the mailer.php file
Find this line
and put in your email id.
Thats it you are good to go.
BTW, I am looking for collaborators to make FlexMailer better, if you're interested drop a comment below.
A question regarding FlexMailer script on StackOverflow