Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Boopathi Rajaa boopathi

💭
I may be slow to respond.
View GitHub Profile
@boopathi
boopathi / gist:57e0e63976d27e969f9c
Last active Sep 6, 2015 — forked from bolshchikov/gist:8069009
Creating read-only JS object
View gist:57e0e63976d27e969f9c
// 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
View q-bluebird.js
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) {
View object-watch.js
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
View whisper-clean.py
import os
import os.path
import sys
from graphite.render.hashing import ConsistentHashRing
## Settings
# Absolute path to the Graphite Data Directory
DATA_DIR = '/data/graphite/whisper/'
## You need not modify anything below this
View gist:4386980
upstream thin {
server unix:/tmp/thin.0.sock;
server unix:/tmp/thin.1.sock;
server unix:/tmp/thin.2.sock;
}
server {
listen 80;
server_name my-domain-name.com
@boopathi
boopathi / server_main.js
Created Nov 11, 2012 — forked from nmorse/server_main.js
basic nowJS on connect and disconnect methods
View server_main.js
var node_static = require('node-static');
var node_static_file = new(node_static.Server)('./client');
var http = require('http'),
players = {},
server = http.createServer(function(req, res) {
// static file server
req.addListener('end', function () {
node_static_file.serve(req, res);
});
}).listen(80);
View Module_subclasses.rb
class Module
def subclasses
classes = []
ObjectSpace.each_object do |klass|
next unless Module === klass
classes << klass if self > klass
end
classes
end
end
View radix_sort.py
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):
@boopathi
boopathi / gist:1020875
Created Jun 11, 2011 — forked from mkuklis/gist:1011477
JavaScript debounce
View gist:1020875
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 / javascript_prototype_objects.js
Created Jun 8, 2011 — forked from thisivan/javascript_prototype_objects.js
Creating Prototype objects with JavaScript
View javascript_prototype_objects.js
// 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);
};