Skip to content

@jpillora
jpillora / join-api-async.coffee
Last active December 22, 2023 22:57
Join API
"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
@cmalven
cmalven / meteor-collection-joins.coffee
Last active December 28, 2015 08:09
Joining collections in Meteor/Mongo
# 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',
@a-x-
a-x- / interpose.coffee
Created November 9, 2018 13:27
interpose like join, but returns an array
# like join, but returns an array
interpose = (array, glue) ->
array.reduce (res,x) -> [].concat res, glue, x
export default interpose
@Syfaro
Syfaro / foxbot.coffee
Created May 30, 2014 21:52
Joins the FurCast IRC channel, spams ":3"s, then leaves and randomly joins again sometime in the next day
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
@tmeasday
tmeasday / gist:4042603
Last active October 12, 2015 14:47
Meteor "Join" -- Note that this code is *not* production ready.
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) =>
@edubkendo
edubkendo / gist:3614027
Created September 3, 2012 22:10
test that our bot says something when someone joins the channel
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()
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
# 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')
@hlship
hlship / flow.coffee
Created March 9, 2012 18:10
Simple callback organizing code
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
@elegantcoder
elegantcoder / README.md
Created September 2, 2012 15:31
Most Common Regexp