Skip to content

Instantly share code, notes, and snippets.

View 1syo's full-sized avatar

Kazunari Takahashi 1syo

View GitHub Profile
# /usr/bin/env bash
export PATH=$HOME/.rbenv/versions/2.3.0-dev/bin/:$PATH
export RUBYLIB=$HOME/.rbenv/versions/2.3.0-dev/lib
rbenv install -f 2.3.0-dev
cd $HOME/rake
git pull --rebase origin master
rake
@1syo
1syo / hubot
Last active August 29, 2015 14:21
if [ -n "$DEBUG" ]; then
exec coffee --nodejs --debug node_modules/.bin/hubot "$@"
else
exec node_modules/.bin/hubot -a slack "$@"
fi
# Description:
# airbrake
HUBOT_AIRBRAKE_KEY=process.env.HUBOT_AIRBRAKE_KEY
module.exports = (robot) ->
robot.router.post "/hubot/airbrake/:room", (req, res) ->
data = { project_id: req.body.error.project.id, notice_id: req.body.error.last_notice.id, group_id: req.body.error.id }
robot.brain.set('airbrake', data)
res.end "Done"
robot.respond /a(?:irbrake)? last( \| (general|backtrace|params|env|session|context))?/i, (msg) ->
@1syo
1syo / spike.coffee
Created May 8, 2015 05:20
httpで受け取った値をbrainしてsendする
# Description:
# spike
module.exports = (robot) ->
robot.router.get "/hubot/spike/:room", (req, res) ->
robot.brain.set('spike', req.params.room)
res.end "Done"
robot.respond /spike/i, (msg) ->
msg.send robot.brain.get('spike')
module KPI
module Summary
class SalesReport
def client
@client ||= Mysql2::Client.new(
host: Settings.kpi.database.host,
database: Settings.kpi.database.xxxxxxx,
username: config['username'],
password: config['password']
)
ADD_RANGE_1 = (-1.50..-0.50)
ADD_RANGE_2 = (0.50..3.50)
ADD_STEP = 0.25
ADD_VALUES = (ADD_RANGE_1.step(ADD_STEP).to_a + ADD_RANGE_2.step(ADD_STEP).to_a).freeze
# config/initializers/constraints.rb
class Home
def matches?(req)
req.params[:id] #=> nil
# .....
end
end
@1syo
1syo / new.travis.yml
Last active August 29, 2015 14:16
.travis.yml
# 前略
env:
- "DB=mysql NUM_GROUPS=10 GROUP=1,2"
- "DB=mysql NUM_GROUPS=10 GROUP=3,4"
- "DB=mysql NUM_GROUPS=10 GROUP=5,6"
- "DB=mysql NUM_GROUPS=10 GROUP=7,8"
- "DB=mysql NUM_GROUPS=10 GROUP=9,10"
before_install: gem install bundler --pre
before_script:
# 中略
require 'bundler/setup'
Bundler.require
class Price
attr_reader :including_tax
def initialize(including_tax)
@including_tax = including_tax
end
@1syo
1syo / main.go
Last active August 29, 2015 14:07
package main
import (
"encoding/json"
"net/http"
"strings"
"time"
"log"
)