This file contains 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
csp.go(function* () { | |
// this routine acts | |
// like the referee | |
var table = csp.chan(); | |
// two routines represents two players | |
// they have access to the same channel | |
csp.go(player, ["ping", table]) | |
csp.go(player, ["pong", table]) |
This file contains 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
// original method | |
function canBeEnhancedLater (x) { | |
return x | |
} | |
// enhancement modules | |
function double (next) { | |
return function (x) { | |
return next(2 * x) |
This file contains 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 getFile (file) { | |
var text, fn; | |
fakeAjax(file, function oldSchoolCb (response) { | |
if (fn) { | |
fn(response) | |
} else { | |
text = response | |
} | |
}) | |
This file contains 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
Handlebars.registerHelper('trimTextWithReadMoreLink', function (textToTrim) { | |
var link, textToShow, el; | |
var wordsAllowed = 30; | |
if ( textToTrim === undefined) { | |
return ""; | |
} | |
var wordsTokenized = textToTrim.split(' '); | |
if (wordsTokenized.length > wordsAllowed) { |
This file contains 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
// MAKING GLOBALS EXPLICIT | |
// ----------------------- | |
// large projects may make finding globals | |
// inside a module confusing | |
// to spot globals easily, lets just | |
// pass it as arguments | |
(function ($, YAHOO) { | |
// now have access to globals jQuery (as $) and YAHOO in this code | |
}(jQuery, YAHOO)); |
This file contains 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
mixin container() | |
table.container(class!=attributes.class) | |
tr | |
td | |
if block | |
block | |
mixin row() | |
table.row(class!=attributes.class) | |
tr |
This file contains 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
1. Two space soft indents (fake tabs) OR tabs... BUT NEVER BOTH - DO NOT MIX | |
2. Whitespace, Parens, Braces, Linebreaks | |
if/else/for/while/try always have spaces, braces and multiple lines. | |
-------------------------------------------------------------------- | |
This file contains 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 Pipeline = function (series, initialInput) { | |
this.series = series; | |
this.initial = function () { | |
return initialInput; | |
}; | |
this.hasPerformed = false; | |
}; | |
Pipeline.prototype.addFunction = function (fn, index) { | |
if (index === undefined) { |
This file contains 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
# FSM Simulation | |
# edges are how an FSM is represented as a data unit | |
# Every edge is a key value pair | |
# A key is a tuple of (current_state, character) | |
# The value is the next state achieved after the previous | |
# state consumes a particular character | |
# r'a+1+' | |
edges = {(1, 'a') : 2, |
This file contains 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
// A general method which splits a metric | |
// expressed in a single smaller unit into multiple | |
// higher units | |
// 1689 minutes => 1 day 9 hours 9 minutes | |
// 1678 millimeter => 1 meter 67 centimeter 8 millimeter | |
// The method takes two parameters, the metric itself | |
// and an array which defines the conversion |