Skip to content

Instantly share code, notes, and snippets.

View mkuklis's full-sized avatar
🏃‍♂️

Michał Kuklis mkuklis

🏃‍♂️
View GitHub Profile
Number.prototype.plus = function(value) {
return this + value;
}
Number.prototype.minus = function(value) {
return this - value;
}
var a = (5).plus(3).minus(6); // 2
function add(n1) {
return function (n2) {
return n1 + n2;
}
}
console.log(add(2)(3)); // 5
multiplexCallback = (function () {
var callbacks = {};
return function(callbackable, callback) {
var callbackList = callbacks[callbackable] || [];
callbackList.push(callback);
if (!callbacks[callbackable]) {
callbacks[callbackable] = callbackList;
callbackable(function () {
@mkuklis
mkuklis / gist:1343722
Created November 6, 2011 22:42
Z1 queue_tip
def queue_tip(*args)
queue = ["A","B","C","D","E","F","G","H"]
return queue if args.size == 0
raise "odd number of arguments" unless args.size.even?
slots = {}
letters = {}
@mkuklis
mkuklis / gist:1291808
Created October 17, 2011 02:23
express + jade + stylus + coffeescript
express = require 'express'
stylus = require 'stylus'
app = express.createServer()
# stylus
app.use stylus.middleware {
debug: true,
src: __dirname + '/public',
dest: __dirname + '/public',
/Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:248: [BUG] Segmentation fault
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
-- control frame ----------
c:0112 p:---- s:0553 b:0553 l:000552 d:000552 CFUNC :read
c:0111 p:0054 s:0549 b:0549 l:000548 d:000548 METHOD /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:248
c:0110 p:0011 s:0540 b:0540 l:000539 d:000539 METHOD /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/processing/rmagick.rb:132
c:0109 p:0015 s:0535 b:0535 l:000525 d:000534 BLOCK /Users/mkuklis/.rvm/gems/ruby-1.9.2-p180@iYouVo/gems/carrierwave-0.5.4/lib/carrierwave/uploader/processing.rb:77
c:0108 p:---- s:0531 b:0531 l:000530 d:000530 FINISH
c:0107 p:---- s:0529 b:0529 l:000528 d:000528 CFUNC :each
@mkuklis
mkuklis / ajaxify-html5.js
Created July 10, 2011 15:26 — forked from balupton/README.md
Ajaxify a Website with the HTML5 History API using History.js and ScrollTo
// https://gist.github.com/854622
(function(window,undefined){
// Prepare our Variables
var
History = window.History,
$ = window.jQuery,
document = window.document;
// Check to see if History.js is enabled for our Browser
@mkuklis
mkuklis / gist:1042935
Created June 23, 2011 16:35
classical inheritance
function inherit(C, P) {
var F = function () {};
F.prototype = P.prototype;
C.prototype = new F();
C._super = P.prototype;
C.prototype.constructor = C;
}
@mkuklis
mkuklis / gist:1030949
Created June 17, 2011 06:19
lazy function definition pattern in JavaScript
var doThisDoThat = function () {
console.log("do this");
doThisDoThat = function () {
console.log("do that");
};
};
doThisDoThat() // do this
doThisDoThat() // do that
@mkuklis
mkuklis / gist:1030922
Created June 17, 2011 05:35
JavaScript test for Array
if (typeof Array.isArray === "undefined") {
Array.isArray = function (arg) {
return Object.prototype.toString.call(arg) === "[object Array]";
};
}