This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
express = require 'express' | |
stylus = require 'stylus' | |
app = express.createServer() | |
# stylus | |
app.use stylus.middleware { | |
debug: true, | |
src: __dirname + '/public', | |
dest: __dirname + '/public', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multiplexCallback = (function () { | |
var callbacks = {}; | |
return function(callbackable, callback) { | |
var callbackList = callbacks[callbackable] || []; | |
callbackList.push(callback); | |
if (!callbacks[callbackable]) { | |
callbacks[callbackable] = callbackList; | |
callbackable(function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(n1) { | |
return function (n2) { | |
return n1 + n2; | |
} | |
} | |
console.log(add(2)(3)); // 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.plus = function(value) { | |
return this + value; | |
} | |
Number.prototype.minus = function(value) { | |
return this - value; | |
} | |
var a = (5).plus(3).minus(6); // 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create file called hgrc in your project under.hg and add: | |
[paths] | |
default-push = ssh://[email protected]/path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = function () { | |
var obj = $.Deferred(); | |
setTimeout(function () { | |
console.log('resolving a'); | |
obj.resolve({a: 1}); | |
}, 1000); | |
return obj; | |
} | |
var b = function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jqmReady = $.Deferred(), | |
pgReady = $.Deferred(); | |
// jqm ready | |
$(document).bind("mobileinit", jqmReady.resolve); | |
// phonegap ready | |
document.addEventListener("deviceready", pgReady.resolve, false); | |
// all ready :) |