Skip to content

Instantly share code, notes, and snippets.

View boopathi's full-sized avatar
💭
I may be slow to respond.

Boopathi Rajaa boopathi

💭
I may be slow to respond.
View GitHub Profile
var B = require("bluebird/js/main/promise")();
var Bproto = B.prototype;
var deferredPrototype = B.pending().constructor.prototype;
deferredPrototype.makeNodeResolver = function() {
return this.asCallback;
};
function bind(fn, ctx) {
@boopathi
boopathi / gist:57e0e63976d27e969f9c
Last active September 6, 2015 16:46 — forked from bolshchikov/gist:8069009
Creating read-only JS object
// lo-dash lib is the dependency
function readOnly(target){
var _readOnly = function (target, acc) {
// acc is passed into the function to be used for observer
var _defineProperty = function (propName, target, acc) {
var i, len;
// operation to be performed when add occurred
@boopathi
boopathi / gist:940390
Created April 25, 2011 11:26 — forked from gf3/gist:361449
Everyones favourite closure!
// everyone's new favorite closure pattern:
(function(window,document,undefined){ ... })(this,this.document);
// when minified:
(function(w,d,u){ ... })(this,this.document);
// which means all uses of window/document/undefined inside the closure
// will be single-lettered, so big gains in minification.
// it also will speed up scope chain traversal a tiny tiny little bit.
@boopathi
boopathi / gitproxy-socat
Created May 10, 2011 18:22 — forked from sit/gitproxy-socat
A simple wrapper around socat to use as a git proxy command
#!/bin/sh
# Use socat to proxy git through an HTTP CONNECT firewall.
# Useful if you are trying to clone git:// from inside a company.
# Requires that the proxy allows CONNECT to port 9418.
#
# Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
# chmod +x gitproxy
# git config --global core.gitproxy gitproxy
#
# More details at http://tinyurl.com/8xvpny
@boopathi
boopathi / gist:985312
Created May 22, 2011 09:45 — forked from paulirish/gist:616412
"iframe" sitedown fallback via <object>
<!-- so it turns out that the object tag can act like an iframe
but the cool thing is you can nest object tags inside eachother for a fallback path.
what this means is you can "objectframe" a site.. and if it fails.. (site down, offline, whatever).. it'll use the next one.
so you can objectframe the live site and fallback to a screenshot.
or something.
demo at : http://jsfiddle.net/paul/CY2FQ/1/
-->
@boopathi
boopathi / utmstrip.user.js
Created May 22, 2011 09:37 — forked from paulirish/utmstrip.user.js
userscript: Drop the UTM params from a URL when the page loads
// ==UserScript==
// @name UTM param stripper
// @author Paul Irish
// @namespace http://github.com/paulirish
// @version 1.1
// @description Drop the UTM params from a URL when the page loads.
// @extra Cuz you know they're all ugly n shit.
// @include http://*
// ==/UserScript==
@boopathi
boopathi / javascript_prototype_objects.js
Created June 8, 2011 06:45 — forked from thisivan/javascript_prototype_objects.js
Creating Prototype objects with JavaScript
// Defining constructor function
function ObjectConstructor(message) {
// TODO: Add your own initialization code here
this.message = message || 'Hello Prototype World!';
};
// Defining an instance function
ObjectConstructor.prototype.sayHello = function() {
alert(this.message);
};
@boopathi
boopathi / gist:1020875
Created June 11, 2011 19:41 — forked from mkuklis/gist:1011477
JavaScript debounce
function debounce(fn, wait) {
var timeout = null;
return function () {
clearTimeout(timeout);
var args = arguments;
var ctx = this;
timeout = setTimeout(function () {
fn.apply(ctx, args);
}, wait);
}
@boopathi
boopathi / radix_sort.py
Created November 26, 2011 09:19 — forked from hiroshi-manabe/radix_sort.py
Radix sort
base = 10
def radix_sort(x, max):
radix = 1
while radix < max:
x = counting_sort(x, radix)
radix *= base
return x
def counting_sort(a, radix):
class Module
def subclasses
classes = []
ObjectSpace.each_object do |klass|
next unless Module === klass
classes << klass if self > klass
end
classes
end
end