Skip to content

Instantly share code, notes, and snippets.

View revathskumar's full-sized avatar

Revath S Kumar revathskumar

View GitHub Profile

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
var Parent = function Parent(){
};
Parent.prototype = {
a:function a(){
console.log(333);
}
};
@revathskumar
revathskumar / debussy13_2.js
Created August 22, 2013 05:27
Google doodle 2013-08-22
(function () {
var h, k = this,
ba = function (a) {
var b = typeof a;
if ("object" == b)
if (a) {
if (a instanceof Array) return "array";
if (a instanceof Object) return b;
var c = Object.prototype.toString.call(a);
if ("[object Window]" == c) return "object";
@revathskumar
revathskumar / a.php
Last active December 20, 2015 15:59
PHP : Add element in the beginning of an array
<?php
$a = array(
1 => "First",
2 => "Second",
5 => "Fifth"
);
?>
.notepad {
background: #f6f6f6;
box-shadow: 0 1px 4px rgba(0,0,0,0.25);
position: relative;
background-image: -webkit-radial-gradient(#e6e6e6 21%, transparent 21%),-webkit-radial-gradient(rgba(0,0,0,0.25) 21%, transparent 26%),-webkit-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 95%, rgba(96,159,159,0.1) 95%, rgba(96,159,159,0.1) 100%);
background-image: -moz-radial-gradient(#e6e6e6 21%, transparent 21%),-moz-radial-gradient(#e6e6e6 10%, transparent 12%),-moz-linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 95%, rgba(96,159,159,0.1) 95%, rgba(96,159,159,0.1) 100%);
background-image: radial-gradient(#e6e6e6 21%, transparent 21%),radial-gradient(#e6e6e6 10%, transparent 12%),linear-gradient(top, rgba(0,0,0,0) 0%, rgba(0,0,0,0) 95%, rgba(96,159,159,0.1) 95%, rgba(96,159,159,0.1) 100%);
background-position: 6px 6px,6px 5px,50% 18px;
background-repeat: repeat-y,repeat-y,repeat;
background-size: 48px 48px,48px 48px,24px 24px;
Rails.application.config.middleware.use OmniAuth::Builder do
configure do |config|
config.path_prefix = "/aircel/auth"
config.full_host = "http://localhost:3000/"
end
provider :developer unless Rails.env.production?
provider :google_oauth2, CONFIG['google_credentials']['client_id'], CONFIG['google_credentials']['client_secret']
end
@revathskumar
revathskumar / Gruntfile.js
Last active December 19, 2015 10:59
Yeoman Livereload for tests
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
@revathskumar
revathskumar / js_inherit
Created July 1, 2013 10:43
Javascript inherit
function inherit(childClass,parentClass) {
var f=function(){}; // defining temp empty function
f.prototype=parentClass.prototype;
f.prototype.constructor=f;
childClass.prototype=new f;
childClass.prototype.constructor=childClass; // restoring proper constructor for child class
parentClass.prototype.constructor=parentClass; // restoring proper constructor for parent class
}
testObj = SomeModule::Test.new
testObj.create_class "airtel" # Creates a new class Airtel
Airtel.new.hello_class # prints Hello from new class
@revathskumar
revathskumar / 1.sh
Last active December 16, 2015 12:49
npm install -g yo