Making post requests with 'request' module in node.js

Was stuck at this for quite some time:

var postData={
	a:1,
	b:2
};
require('request').post({
	uri:"http://example.com/test",
	headers:{'content-type': 'application/x-www-form-urlencoded'},
	body:require('querystring').stringify(postData)
	},function(err,res,body){
		console.log(body);
		console.log(res.statusCode);
});

This will make a post request to http://example.com/test with the querystring parameters in postData. Meaning if you are using PHP, you can see the variables in $_POST instead of parsing request body.

References:

The only way I can work any longer

Being a good programmer is 3% talent and 97% not getting distracted by the Internet.

Firstly, a frank admission.

I procastinate.
A lot.
Seriously.

For every second I spend in front of my computer, trying to get some work done, there is a continous struggle going on between my “work” and “play” side of things. Unfortunately, the “play” side seems to be winning. A lot. So I decided to wage a war against it.

Here is my arsenal of tools:

  • get-shit-done - Script blocks all access to various sites(FB,reddit etc)
  • Chrome Profiles - One of my profiles is called “get-shit-done”. It features my development extensions, apps, bookmarks, and nothing else. It is plain vanilla Chromium with no puffy unicorns luring me to check my Facebook Notifications.
    Chrome Profiles
  • Music - I find Youtube a surprising good source of music discovery. I listen to almost everything. Recently, I’ve started to listen to Ludovico Einaudi. You may also like http://musicforprogramming.net/ in this regard.
  • Minimal Tabs - I close a tab as soon as I’m done with it. This leads to ~3-5 tabs in my “get-shit-done” setup. A lesser number of tabs usually means a limit on the number of distracting links. Even Stackoverflow doesn’t help in this regard.
  • The get-shit-done profile even has settings to clear cache at closings. This leads to me being signed out of everything. Including GMail, Facebook, SO, and everything else. In this mode, I login to something, if it is essential to the work at hand.
  • Read It Later - I’ve setup all Hacker News feeds above 20 points to be saved automatically to my Read It Later account, which I can easily consume on my iPad at my leisure. However, I find myself itching to browse hckrnews every 5 minutes.

If you find yourself browsing facebook, reddit, youtube, hacker news, or reading blog posts on productivity, I urge you strongly to try this out. Defeating procastination is not easy. And its never a win-or-lose battle. What are your thoughts? How do you stop yourself from getting lost on the internetz? Tell me in comments.

Things I love about Github

A slide from GitHub’s famous “How Github uses Github to build Github talk”:

In their recent version of the talk at RubyConf 2011, they changed the slide slightly:

No pings

It now reads, “No Pings” instead of “No Managers”.

Not nitpicking, just paying attention.

If you haven’t seen the talk (or just saw the slideshow), you should go and watch the talk (31 mins) Right Now