Skip to content

Instantly share code, notes, and snippets.

View kakts's full-sized avatar

Keita Akutsu kakts

View GitHub Profile
var _ = require('lodash');
var list = ['a', 'b', 'c', 'd'];
_.each(list, function(data) {
console.log('------', data);
if (data === 'b') {
return false;
}
console.log('-----after');
@kakts
kakts / gist:0e5c35f44395845e2972
Created January 23, 2016 06:40
Installing hubot packages.
// Installing hubot coffee-script
$ npm install -g hubot coffee-script
// Cheking hubot version
$ hubot -v
2.18.0
// After hubot version 2.9, we use generator-hubot when initializing hubot.
$ npm install -g yo generator-hubot
@kakts
kakts / gist:eeb935f1c13ac8788ef9
Created January 23, 2016 06:42
initilizing hubot
$ yo hubot
_____________________________
/ \
//\ | Extracting input for |
////\ _____ | self-replication process |
//////\ /_____\ \ /
======= |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
@kakts
kakts / gist:bf1804234b9680fc9bcb
Created January 23, 2016 06:47
hubot directory.
$ tree -L 2
.
├── Procfile
├── README.md
├── bin
│   ├── hubot
│   └── hubot.cmd
├── external-scripts.json
├── hubot-scripts.json
├── node_modules
@kakts
kakts / gist:21af5086758980278b2f
Created January 23, 2016 06:54
hubot pong response
module.exports = (robot) ->
robot.hear /ping/i, (res) ->
res.send "pong"
$ bin/hubot
hubot-slack> [Sat Jan 23 2016 15:58:38 GMT+0900 (JST)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web-url | cut -d= -f2)`
[Sat Jan 23 2016 15:58:38 GMT+0900 (JST)] INFO hubot-redis-brain: Using default redis on localhost:6379
hubot-slack> ping
hubot-slack> pong
# ここでターミナルからherokuへのログインを行う
$ heroku login
# herokuのアプリケーション作成 XXXXはアプリ名
$ heroku create XXXX
# ここで作成したhubotディレクトリ(以前作成したhubot-slackディレクトリ)へ移動する
$ cd ./hubot-slack
# herokuにコミットする git commitして、herokuにpushする
# 作成したhubotディレクトリ直下で以下のコマンドを実行する
# package.jsonにhubot-slackの情報を記述するため、-gコマンドはつけず、--saveをつける
$ npm install hubot-slack --save
# hubotディレクトリ直下のProcfileを以下の内容に変える
web: bin/hubot --adapter slack
#変更後、git commit してherokuにpushする
git add --all
#tokenをコンフィグ値に設定する
$heroku config:set HUBOT_SLACK_TOKEN=????_???????????
// hubotスクリプトのディレクトリへ移動して
// hubot-heroku-keepalive をインストール
$ cd hubot-sciript-dir
$ npm install hubot-heroku-keepalive --save
// ./external-scripts.jsonに以下の文字列を追記する
"hubot-heroku-keepalive"
// 修正した分をherokuにpushする
$ git add -A