Skip to content

Instantly share code, notes, and snippets.

View m4r00p's full-sized avatar

Marek Pawłowski m4r00p

View GitHub Profile
@m4r00p
m4r00p / hex to rgb
Created August 12, 2013 22:49
Converts hex color value to rgb array.
var hex2rgb = function (hex) {
return hex.match(/(\w{2})/gi).map(function(n){return parseInt(n,16);});
};
@m4r00p
m4r00p / bind.js
Created February 20, 2013 23:24
Elaborate about Function.prototype.bind and polyfills.
// Case 1:
// Bind clean way.
var obj = {
a: 'obj ',
fn: function (b) {
console.log(this.a + b);
},
attachEvents: function () {
this.attachEvent('onSomething', this.fn.bind(this, 'argB'));
}
@m4r00p
m4r00p / NodeCombiningWebProxy
Created October 2, 2012 17:29
Proxy combining local and external web services.
var express = require('express'),
app = express(),
http = require('http'),
httpProxy = require('http-proxy');
//Express config
//app.set('view engine', 'ejs');
//app.set('views', __dirname + '/views');
app.use(express.cookieParser());
app.use(express.methodOverride());
@m4r00p
m4r00p / r-proto-class.js
Created November 15, 2011 12:26 — forked from DmitrySoshnikov/r-proto-class.js
R-Proto-Class.js
/**
* r-proto-class.js
* Ruby's semantics
*
* Features:
* - super calls
* - using Object.create for inheritance
* - Class.new is a wrapper over Class.allocate and Class.initialize
*
* by Dmitry Soshnikov <[email protected]>