Skip to content

Instantly share code, notes, and snippets.

// messenger.js
// dependency setup
var hook_url = MY_HOOK_URL;
var Slack = require('node-slack');
var slack = new Slack(hook_url);
module.exports = {
sendMessage: function(message, channel, username) {
if (!message){
console.log('Error: No message sent, you must define a message.')
} else {
// This pattern gives you full control of how JavaScript steps through an array loop, and is an alternative of using array.forEach or a "for" loop.
// The best use case for this is if you need to wait for operations like ajax requests to complete before continuing the loop.
var array = [1,2,3,4,5,6,7];
var looper = function(item){
if(item){
// do an ajax request, or some operation that takes time
fireAjaxRequest(item, function(results){
// do something with the results, then continue the loop
function getPersonEmoji(){
var personArray = [
":woman::skin-tone-2:",
":woman::skin-tone-3:",
":woman::skin-tone-4:",
":woman::skin-tone-5:",
":woman::skin-tone-6:",
":woman::skin-tone-6:",
":person_with_blond_hair::skin-tone-2:",
":person_with_blond_hair::skin-tone-3:",
cory-shaws-macbook-pro-2:haystack coryshaw$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10.2.0]
cory-shaws-macbook-pro-2:haystack coryshaw$ gem -v
1.3.5
cory-shaws-macbook-pro-2:haystack coryshaw$ gem list mongo
*** LOCAL GEMS ***
mongo (0.18.1)
mongo_ext (0.18.2)
cory-shaws-macbook-pro-2:haystack coryshaw$ rake gems:install --trace
(in /Users/coryshaw/Development/haystack)
** Invoke gems:install (first_time)
** Invoke gems:base (first_time)
** Execute gems:base
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant Mongo::InvalidDocument
/Users/coryshaw/Development/haystack/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant'
<div class="restaruant">
<img class="photo" alt="The Poke Bowl Photo" title="The Poke Bowl" align="right" src="http://static.px.yelp.com/bpthumb/18IOFXZvIM30VnTZj22Qlg/ms"/>
<h3>The Poke Bowl</h3><img align="absmiddle" class="rating" alt="Rating for The Poke Bowl" title="Rating 4.5 stars" src="http://static.px.yelp.com/static/20090923/i/new/ico/stars/stars_3.png"><a class="reviews" href="#reviewsLink">187 Reviews</a><br/>
<p>&quot;True to the name, this is more of a poke on rice bowl, rather than a spicy ahi don (spicy ahi on rice bowl). The ahi is like most poke, larger chunks. Also, i really really like their poke because it is fresh and warm and stuffs. They season it with lots of goods like onions and other things which are tasty.&quot; <span>- Don 03/04/09</span></p>
</div><!-- end restaurant -->