Skip to content

Instantly share code, notes, and snippets.

View m4r00p's full-sized avatar

Marek Pawłowski m4r00p

View GitHub Profile
@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 <dmitry.soshnikov@gmail.com>
@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 / 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 / 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 / looped-deferred.js
Last active December 21, 2015 08:29
Looped deferred
var getDeferred = function (i) {
var deferred = new $.Deferred();
setTimeout(function () {
if (--i) {
deferred.resolve(i);
} else {
deferred.reject(i);
}
}, 2000);
function loadContent(href, pushState) {
var el = $('<div></div>');
el.load(href + ' .placeholder', function (response, status, xhr) {
if (status === 'error') {
w.location = href;
} else {
if (pushState) {
window.history.pushState({}, document.title, href);
}
@m4r00p
m4r00p / .vimrc
Created December 30, 2015 20:24
.vimrc
"NeoBundle Scripts-----------------------------
if has('vim_starting')
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath+=/Users/marekpawlowski/.vim/bundle/neobundle.vim/
endif
find . -type f -name '*.js' -exec sed -i '' s/.jsx//g {} +
@m4r00p
m4r00p / 4to2spaces.sh
Last active October 10, 2018 10:35
4 spaces to 2 spaces
find . -type f -exec sed -i.orig 's/ / /g' {} +
@m4r00p
m4r00p / png2jpg.sh
Created March 8, 2018 11:13
png to jpg
for i in *.png; do sips -s format jpeg $i --out $i.jpg ;done