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 optimist = require('optimist') | |
optimist.demand('color') | |
optimist.demand('size') | |
optimist.argv |
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
// Flow is a construct that can chain together functions. | |
// Flow denotes regular function composition. | |
var chain1 = | |
Flow <- f1 | |
<- f2 | |
<- f3 | |
chain1(123) // same as f3(f2(f1(123))) | |
// Can also chain together multiple things that go to one. |
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
//From http://wiki.ecmascript.org/doku.php?id=harmony:proxies | |
function handlerMaker(obj) { | |
return { | |
getOwnPropertyDescriptor: function(name) { | |
var desc = Object.getOwnPropertyDescriptor(obj, name); | |
// a trapping proxy's properties must always be configurable | |
if (desc !== undefined) { desc.configurable = true; } | |
return desc; | |
}, | |
getPropertyDescriptor: function(name) { |
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 items [:rock :paper :scissors]) | |
(defn winner [m1 m2] | |
(mod (- m1 m2 1) 3)) | |
(defn player-string [name symbol] | |
(str name (nth items symbol) " wins!")) | |
(defn player-wins [m1 m2] | |
(str (nth items m1) " vs. " (nth items m2) " !! " |
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.prototype.ac = (function(){ | |
return ac; | |
function ac(len, bind, args){ | |
var func = this | |
, args = args || []; | |
return function internal(){ | |
args = args.concat(Array.prototype.slice.call(arguments)); | |
len -= arguments.length; | |
if (len > 0) return internal; | |
else func.apply(bind, args); |
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 fs = require('fs'); | |
var path = require('path'); | |
var sys = require('sys') | |
, limit = 50 | |
, count = 0; | |
function copytree(src, dst) { | |
if(!path.existsSync(src)) { | |
throw new Error(src + ' does not exists. Nothing to be copied'); | |
} |
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(){ | |
this.Class = function(params){ | |
if (params instanceof Function) params = {initialize: params}; | |
var newClass = function(){ | |
this.Object.reset(this); | |
if (newClass._prototyping) return this; | |
this._current = $empty; | |
var value = (this.initialize) ? this.initialize.apply(this, arguments) : this; |
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
require('./getter').grabInto(['./docs'], GLOBAL); | |
var path = './'; | |
exports.generateDocs = function(out, files, format){ | |
files = (files instanceof Array ? files : [files]); | |
var output = require(format).output; | |
files.forEach(function(file) { | |
out('OUTPUTING ' + file + ' starting\n\n'); | |
require(path + file); | |
getDoced().forEach(function(item) { | |
output(out, item); |
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
/* | |
Script: Keyboard.js | |
KeyboardEvents used to intercept events on a class for keyboard and format modifiers in a specific order so as to make | |
alt+shift+c the same as shift+alt+c. | |
License: | |
MIT-style license. | |
Authors: | |
Perrin Westrich |
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
APE.Move = new Class({ | |
Implements: [Options], | |
Extends: APE.UserClient, | |
options: { | |
container: document.body, | |
userEvents: [{cmd: 'send', raw: 'data'}, {cmd: 'setPos', raw: 'positions'}] | |
}, |
NewerOlder