Languages
2,103 gist results
2,103 gist results
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
"use strict" | |
api1 = | |
a: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+1), 500 | |
b: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+2), 500 | |
api2 = | |
b: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+3), 500 | |
c: (x,y,z,cb) -> setTimeout cb.bind(null, null, x+y+z+4), 500 | |
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
# In an Iron Router Route (requires that the below publication is also set up) | |
# ===================================== | |
Router.configure | |
layoutTemplate: 'layout' | |
loadingTemplate: 'loading' | |
Router.map -> | |
@route 'member_show', |
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
# like join, but returns an array | |
interpose = (array, glue) -> | |
array.reduce (res,x) -> [].concat res, glue, x | |
export default interpose |
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
irc = require 'irc' | |
client = new irc.Client 'irc.ircfox.net', 'FoxBot' | |
String.prototype.repeat = (num) -> | |
return new Array(num + 1).join this | |
randomNumber = (min, max) -> | |
return Math.floor Math.random() * (max - min) + min |
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
Meteor.publish 'paths', (since) -> | |
pointHandles = {} | |
publishPath = (pathId) => | |
pointHandles[pathId] = Points.find({pathId: pathId}).observe | |
added: (obj) => | |
@set('points', obj._id, obj) | |
@flush() | |
# these two should never happen | |
changed: (obj) => |
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
it "should say something when someone joins the channel", (done) -> | |
server = net.createServer() | |
server.listen(6667, 'localhost') | |
server.on 'connection', (socket) -> | |
socket.emit "join", "bottest123", "server", "test" | |
socket.on 'data', () -> | |
socket.end() | |
server.close() | |
done() |
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
client.addListener 'join', (@channel, who) -> | |
unless who is "TowerBot" | |
client.say channel, "Hello #{who}! If you have a question, please be patient! It may take some time before someone sees it, but we will try our best to help you." | |
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
class Batman.SetTransform extends Batman.Set | |
constructor: (@source, observedItemKeys..., @transform) -> | |
super() | |
@transformIndex = new Batman.SimpleHash | |
if @source.isObservable | |
@_setObserver = new Batman.SetObserver(@source) | |
@_setObserver.observedItemKeys = observedItemKeys | |
@_setObserver.observerForItemAndKey = @observerForItemAndKey | |
@_setObserver.on 'itemsWereAdded', @add | |
@_setObserver.on 'itemsWereRemoved', @remove |
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
# Gulp and plugins | |
gulp = require('gulp') | |
gutil = require('gulp-util') | |
plugins = require("gulp-load-plugins")(scope: ["dependencies", "devDependencies"]) | |
# Utilities | |
grunt = require('grunt') | |
glob = require('glob') | |
path = require('path') |
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
event = require "events" | |
_ = require "underscore" | |
# Helps to organize callbacks. At this time, it breaks normal | |
# conventions and makes not attempt to catch errors or fire an 'error' | |
# event. | |
class Flow extends event.EventEmitter | |
constructor: -> | |
@count = 0 |