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
/** | |
* # Post messages using Slack's Webhook | |
* | |
* Use this in combination with node-cron to Schedule messages. | |
* No need to have the hubot invited on the actual channel to post. | |
* | |
* ## Dependencies | |
* | |
* superagent | |
* lodash |
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
# Description: | |
# Hubot delivers a pic from Reddit's /r/holdmybeer frontpage if it is a friday | |
# based on the aww script. | |
# | |
# Dependencies: | |
# moment | |
# | |
# Configuration: | |
# None | |
# |
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
# Description: | |
# Hubot make me a sandwich | |
# | |
# Dependencies: | |
# google-images | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: |
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
# Description: | |
# Hubot delivers a fika related pic | |
# | |
# Dependencies: | |
# cron | |
# google-images | |
# | |
# Configuration: | |
# None | |
# |
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 Errors = Reflux.createActions(['error1', 'error2' /*, 'error3' */]); | |
var ErrorNotificationStore = Reflux.createStore({ | |
init: function() { | |
_.each(Errors, function(action) { | |
this.listenTo(action, this.onError); | |
}, this); | |
}, | |
onError: function(errorMessage) { | |
/* whatever you want to do with errorMessage and this.trigger(...) */ |
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
/** @jsx React.DOM */ | |
var React = require('react'), | |
Reflux = require('reflux'), | |
toggle = Reflux.createAction(), | |
userStore = Reflux.createStore({ | |
init: function() { | |
this.notify = false; | |
this.listenTo(toggle, this.onToggle); | |
}, | |
onToggle: function(flag) { |
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 PostsApi = require('webapi/posts'), | |
// assuming the api object from the jsbin snippet | |
Reflux = require('reflux'); | |
var PostActions = createActions(["load", "loadError"]); | |
// load action is invoked either from: | |
// * top most component's componentDidMount | |
// function in your application, or | |
// * window.onLoad | |
// I prefer the first strategy because that'll |
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
/** | |
* Generates normally distributed random numbers | |
*/ | |
function normalRandom(mean, stdDev) { | |
// Generate a "close enough" uniform random | |
// number w. mean = 0 and std.dev = 1 | |
var uniformRandom = (Math.random()*2-1)+(Math.random()*2-1)+(Math.random()*2-1); | |
return Math.round(uniformRandom * stdDev + mean); | |
} |
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() { | |
var defaultFrameRate = 20, // fps lock for old browsers | |
// This is the default fallback throttle function | |
framerateThrottle = function(callback) { | |
return _.throttle(callback, 1 / (defaultFrameRate * 1000)); | |
}; | |
// Feature detection - should have requestAnimationFrame | |
if (window.requestAnimationFrame) { | |
framerateThrottle = function(callback) { |
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 EventEmitter = require('events').EventEmitter, | |
_ = require('lodash'); | |
/** | |
* Creates an action functor object | |
*/ | |
exports.createAction = function() { | |
var action = new EventEmitter(), | |
eventLabel = "action", |