Skip to content

Instantly share code, notes, and snippets.

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

Michał Kuklis mkuklis

🏃‍♂️
View GitHub Profile
@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',
@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 = {}
multiplexCallback = (function () {
var callbacks = {};
return function(callbackable, callback) {
var callbackList = callbacks[callbackable] || [];
callbackList.push(callback);
if (!callbacks[callbackable]) {
callbacks[callbackable] = callbackList;
callbackable(function () {
function add(n1) {
return function (n2) {
return n1 + n2;
}
}
console.log(add(2)(3)); // 5
Number.prototype.plus = function(value) {
return this + value;
}
Number.prototype.minus = function(value) {
return this - value;
}
var a = (5).plus(3).minus(6); // 2
@mkuklis
mkuklis / gist:1384978
Created November 22, 2011 05:33
playing around with canvas :)
(function () {
// global
var w = this
, d = w.document
// valid attributes
, vattrs = {x:1,y:1,cx:1,cy:1,r:1,w:1,h:1,fill:1,path:1}
// path commands
, pathCommands = {
M: function (v) {
@mkuklis
mkuklis / gist:1511032
Created December 22, 2011 17:09
mercurial push to default repo
# create file called hgrc in your project under.hg and add:
[paths]
default-push = ssh://[email protected]/path
@mkuklis
mkuklis / gist:1552169
Created January 2, 2012 21:19
more experiments with canvas
// demo: http://jsfiddle.net/7wG3a/14/
var c = document.getElementById('canvas');
var ctx = c.getContext('2d');
var drawing = false, dx, dy;
var x = 100, y = 100, w = 100, h = 100;
c.onmousedown = function (e) {
dx = e.clientX - x;
dy = e.clientY - y;
drawing = true;
@mkuklis
mkuklis / gist:2046692
Created March 15, 2012 20:28
playing with deferred objects
var a = function () {
var obj = $.Deferred();
setTimeout(function () {
console.log('resolving a');
obj.resolve({a: 1});
}, 1000);
return obj;
}
var b = function () {
@mkuklis
mkuklis / gist:2321307
Created April 6, 2012 16:56
PhoneGap JQM Initialization
var jqmReady = $.Deferred(),
pgReady = $.Deferred();
// jqm ready
$(document).bind("mobileinit", jqmReady.resolve);
// phonegap ready
document.addEventListener("deviceready", pgReady.resolve, false);
// all ready :)