Skip to content

Instantly share code, notes, and snippets.

View shokai's full-sized avatar

Sho Hashimoto shokai

View GitHub Profile
@shokai
shokai / Makefile
Last active August 29, 2015 14:08
Gyazz osusume登録ブックマークレット
all: build
build:
echo "javascript:" | tr -d '\n' > bookmarklet.js
uglifyjs src.js >> bookmarklet.js
# Description:
# encodeされたURLを日本語に戻す
#
# Author:
# @shokai
module.exports = (robot) ->
robot.hear /(https?:\/\/[^ ]+)/i, (msg) ->
@shokai
shokai / hubot-ore-api.coffee
Last active August 29, 2015 14:06
俺APIからのmoveイベントをhubotに通知する
debug = require('debug')('hubot-ore-api')
config =
url: 'https://ore-api.herokuapp.com'
slack:
room: "#news"
module.exports = (robot) ->
socket = require('socket.io-client').connect config.url
# Description:
# hubot anonymous post
#
# Commands:
# hubot anon MESSAGE
# hubot anon #general MESSAGE
#
# Author:
# @shokai
# Description:
# Gyazz更新通知
# /hubot/gyazz-webhook へのPOSTリクエストを受信
#
# Dependencies:
# "diff": "*"
# "debug": "*"
#
# Author:
# @shokai
def wh(uA)
raise ArgumentError, "argument must be instance of Array" unless uA.kind_of? Array
uA.each do |url|
puts "#{url}について何か処理する"
end
end
wh ["かずどん", "zanmai"]
## 1つランダムに選ぶ
_ = require 'lodash'
module.exports = (robot) ->
robot.respond /choice (.+)/i, (msg) ->
items = msg.match[1].split(/\s+/)
choice = _.sample items
msg.send "厳正な抽選の結果、「#{choice}」に決まりました"
noble = require 'noble'
_ = require 'lodash'
UUIDs =
service: "713d0000-503e-4c75-ba94-3148f18d941e".replace(/\-/g, '')
tx: "713d0003-503e-4c75-ba94-3148f18d941e".replace(/\-/g, '')
rx: "713d0002-503e-4c75-ba94-3148f18d941e".replace(/\-/g, '')
noble.on 'discover', (peripheral) ->
if peripheral.advertisement.localName is "BlendMicro"
noble = require 'noble'
noble.on 'discover', (peripheral) ->
if peripheral.advertisement.localName is "BlendMicro"
console.log "device found"
peripheral.on 'connect', (arg) ->
console.log 'connect!!'
peripheral.connect()
@shokai
shokai / chat-post.coffee
Last active August 29, 2015 14:01
npm install slackbot
Slackbot = require 'slackbot'
slackbot = new Slackbot 'masuilab', process.env.SLACK_TOKEN
slackbot.send '#general', process.argv[2] or "ヘーイ提督ー"