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
do -> do factorial = (n = 5) -> | |
if n <= 1 then 1 else n * factorial(n-1) |
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
regexps = | |
code: regex.code | |
url: regex.url | |
channel: regex.channel | |
parse = (str) -> | |
strings = [{text: str}] | |
for name, regexp of regexps | |
for string, i in strings | |
if not string.token? and matches = string.text.match regexp |
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
regexps = [ | |
regexp: /`([^`]*)`/g | |
flag: 'code' | |
, | |
regexp: /\*\*([^\*]*)\*\*/g | |
flag: 'bold' | |
, | |
regexp: /\*([^\*]*)\*/g | |
flag: 'em' | |
, |
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
ptext = ptext.replace(/`([^`]*)`/g, "<code>$1</code>") | |
.replace(/\*\*([^\*]*)\*\*/g, "<strong>$1</strong>") | |
.replace(/\*([^\*]*)\*/g, "<em>$1</em>") | |
.replace(/_([^_]*)_/g, '<span class="underline">$1</span>') | |
.replace(/#(\d*[a-zA-Z_]+)/g, '<a href="/channels/$1">#$1</a>') |
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
this.update = function(collection, query, field, update) { | |
// Set up this object to pass in to the mongo update method. | |
$set = {}; | |
// Create the $set object for mongo's update method by passing | |
// the doc's 'field' to the 'update' argument. | |
$set[field] = _.compose(update, _.reduce)(field.split('.') | |
, function(memo, accessor) { | |
return memo[accessor] // Get field from the doc. | |
}, collection.findOne(query)); |
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
@update = (collection, query, field, update) -> | |
# Set up this object to pass in to the mongo update method. | |
$set = {} | |
# Create the $set object for mongo's update method by passing | |
# the doc's 'field' to the 'update' argument. | |
$set[field] = _.compose(update, _.reduce) field.split('.') | |
, (memo, accessor) -> memo[accessor] # Get field from the doc. | |
, collection.findOne(query) |
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
JSGame.game = function(options) { | |
JSGame.initKeyboard(); | |
$(document).ready(function() { | |
var defaults = { | |
// default options | |
fps: 60, | |
fullscreen: false, | |
width: 800, |
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
do -> | |
cache = {} | |
viewKey = 'ttView' | |
methods = | |
initialize: (datasetDefs) -> | |
datasetDefs = utils.isArray(datasetDefs) ? datasetDefs : [datasetDefs] | |
if datasetDefs.length == 0 | |
$.error('no datasets provided') |
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
Entity = function (name, stats) { | |
this.ui = { | |
healthBar: $('<div id="healthBar" class="progress-bar progress-bar-danger"></div>') | |
manaBar: $('<div id="healthBar" class="progress-bar progress-bar-danger"></div>') | |
}; | |
// Append UI | |
$('body').append(this.ui.healthBar); | |
$('body').append(this.ui.manaBar); |
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
# Update the status bar by fetching an environment variable set earlier by a shell script. | |
# Requires Thomas Adam's hook patch for tmux | |
# https://github.com/ThomasAdam/tmux/tree/ta/hooks | |
set-hook -g -n 'after-select-window' 'run "tmux set -q status-left \"`tmux show -environment TMUX_STATUS_#I | cut -c 15-`\""' | |
set-hook -g -n 'after-kill-window' 'run "tmux set -q status-left \"`tmux show -environment TMUX_STATUS_#I | cut -c 15-`\""' |
NewerOlder