Skip to content

Instantly share code, notes, and snippets.

Avatar

manaten manaten

View GitHub Profile
@manaten
manaten / ghe-event.coffee
Created Feb 17, 2015
gheのissuecommentを各人にslackDMで通知
View ghe-event.coffee
#
# Description:
# Watch and emit github events.
# see https://developer.github.com/v3/activity/events/types/
#
# Dependencies:
# cron, request, config, lodash
#
# Configuration:
# config.github.organizations 監視したいgheのorg名をキーとするオブジェクト
View gist:a5e3f55941c2c864da3f
express = require 'express'
request = require 'request'
app = express()
app.get '/', (req, res) -> res.send 'test!!!'
mockHttpServer = app.listen 3011, ->
request 'http://localhost:3011', (err, res, body) ->
console.log body
mockHttpServer.close()
View gist:a1d2467ec571f5cac730
me = new MutualExclusion;
var hogeProcess = function(args, done) {
me.do(function(done) {
someAsync(function(err, result) {
done(err, result);
});
}, done);
}
@manaten
manaten / gist:22b5793ccc0660f96dba
Created Dec 9, 2014
全てのメッセージにアイコンを付けるスクリプト
View gist:22b5793ccc0660f96dba
#
# Description:
# Add hubot icon to bot message.
#
# Dependencies:
# None
#
# Configuration:
# None
#
@manaten
manaten / gist:2c2df56accfe590df215
Last active Aug 29, 2015
hubot で configで指定している以外のチャンネルでhearした場合につぶやかないスクリプト。最初に読まれるように _ とかでファイル名を始める
View gist:2c2df56accfe590df215
# Description:
# Force hubot hearing messages only in rooms.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
View gist:75c97f59235a086664f2
mkdir test_repo
cd test_repo
git init
touch test.txt
git add .
git commit -m 'initial commit'
echo hoge >> test.txt
git add .
git commit -m 'second commit'
git log
@manaten
manaten / gist:7a7d9c5cc843f1dbf31b
Last active Aug 29, 2015
HubotにQRコード作らせる
View gist:7a7d9c5cc843f1dbf31b
# Description:
# Show qr-code.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
View gist:9433910
<?php
preg_match('/^[0-9]+$/', $hoge);
preg_match('/^[a-zA-Z0-9_\-]+$/', $hoge);
@manaten
manaten / hook.php
Last active Dec 19, 2015
PHP webhook program.
View hook.php
<?php
$LOG_FILE = dirname(__FILE__).'/hook.log';
$SECRET_KEY = '** secret **';
if ( isset($_GET['key']) && $_GET['key'] === $SECRET_KEY && isset($_POST['payload']) ) {
$payload = json_decode($_POST['payload'], true);
if ($payload['ref'] === 'refs/heads/master') {
`cd /path/to/repository; git pull origin master`;
file_put_contents($LOG_FILE, date("[Y-m-d H:i:s]")." ".$_SERVER['REMOTE_ADDR']." git pulled: ".$payload['head_commit']['message']."\n", FILE_APPEND|LOCK_EX);
@manaten
manaten / gist:5486754
Created Apr 30, 2013
Generatorでこんなことが出来ればいいのに、という夢
View gist:5486754
var Sprite = function(){
this.x = 0;
this.v = 0.5;
};
// x方向に引数で与えた分だけ速度vで進む
Sprite.prototype.move = function(x) {
var time = x / this.v;
for (var i = 0; i < time; i++) {
this.x += this.v;
yield;
You can’t perform that action at this time.