Skip to content

Instantly share code, notes, and snippets.

View manaten's full-sized avatar
🐢
I'm LAZY monster

manaten manaten

🐢
I'm LAZY monster
View GitHub Profile
alert('こんにちはこんにちは!');
@manaten
manaten / fizzbuzz.js
Last active December 16, 2015 05:39
FizzBuzz
for(i=21;--i;)console.log(i%3?i:"Fizz",i%5?i:"Buzz")
@manaten
manaten / gist:5486754
Created April 30, 2013 05:34
Generatorでこんなことが出来ればいいのに、という夢
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;
@manaten
manaten / hook.php
Last active December 19, 2015 17:19
PHP webhook program.
<?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);
<?php
preg_match('/^[0-9]+$/', $hoge);
preg_match('/^[a-zA-Z0-9_\-]+$/', $hoge);
@manaten
manaten / gist:7a7d9c5cc843f1dbf31b
Last active August 29, 2015 14:03
HubotにQRコード作らせる
# Description:
# Show qr-code.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
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:2c2df56accfe590df215
Last active August 29, 2015 14:10
hubot で configで指定している以外のチャンネルでhearした場合につぶやかないスクリプト。最初に読まれるように _ とかでファイル名を始める
# Description:
# Force hubot hearing messages only in rooms.
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@manaten
manaten / gist:22b5793ccc0660f96dba
Created December 9, 2014 03:51
全てのメッセージにアイコンを付けるスクリプト
#
# Description:
# Add hubot icon to bot message.
#
# Dependencies:
# None
#
# Configuration:
# None
#
me = new MutualExclusion;
var hogeProcess = function(args, done) {
me.do(function(done) {
someAsync(function(err, result) {
done(err, result);
});
}, done);
}