Skip to content

Instantly share code, notes, and snippets.

View shokai's full-sized avatar

Sho Hashimoto shokai

View GitHub Profile
@shokai
shokai / ex9.rb
Last active August 29, 2015 14:22
# a^2 + b^2 == c^2 かつ a+b+c=1000, a < b < c となる a, b, c を求める
1.upto(998).each do |a|
(a+1).upto(999).each do |b|
c = 1000-a-b
left = a*a + b*b
right = c*c
break if left > right
if left == right
puts "#{a}^2 + #{b}^2 == #{c}^2"
@shokai
shokai / a.js
Last active August 29, 2015 14:22
throttle/debounce
// すぐ実行、終わるまで排他する
locks = {}
var function = openDoor(where){
if(locks[where]) return;
locks[where] = true;
arduino.servoWrite(180, 11); // サーボ回す
setTimeout(function(){
arduino.servoWrite(0, 11); // サーボの位置を戻す
locks[where] = false;
}, 5000);
@shokai
shokai / circleci-webhook.coffee
Last active August 29, 2015 14:21
Circle CI Webhook for Hubot
# Description:
# Circle CI Webhook
#
# Author:
# @shokai
config =
room: "#news"
debug = require('debug')('hubot:circleci-webhook')

Contributor Code of Conduct

As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.

Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from th

Process: Gyazo [98235]
Path: /Applications/Gyazo.app/Contents/MacOS/Gyazo
Identifier: com.gyazo.mac
Version: 2.1 (2.1)
Code Type: X86-64 (Native)
Parent Process: launchd [287]
Responsible: Gyazo [98235]
User ID: 501
Date/Time: 2015-05-17 00:32:01.978 +0900
#!/bin/sh
TMP=/tmp/gsay.mp3
curl --silent --user-agent "Safari/1.0" "http://translate.google.com/translate_tts?q=$1&tl=ja" > $TMP && afplay $TMP && rm -f $TMP
@shokai
shokai / GMapUtil.java
Last active July 9, 2018 22:53
Android版Google Mapsアプリの「共有」メニューから送られてくるIntentの短縮URLから、緯度経度を調べる
// google mapsの短縮URLから緯度経度を調べる
// AndroidのGoogleMapの「共有」から得られるURLが対象
// Web版mapから得られるURLにはcidが無いので無理
// GMapUtil.getLocation(Intent, Callback); から使う
// MIT License
package org.shokai.gmapstars;
import android.content.Intent;
import android.os.AsyncTask;
@shokai
shokai / setTimeout.rb
Last active August 29, 2015 14:15
RubyでsetTimeout
## gem install concurrent-ruby-ext が必要
## http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ScheduledTask.html
require 'concurrent'
task1 = Concurrent::ScheduledTask.execute 1 do
puts "1秒たった"
end
task2 = Concurrent::ScheduledTask.execute 2 do
# Description:
# notify "star_added" event for slack.com
#
# Author:
# @shokai <hashimoto@shokai.org>
debug = require('debug')('hubot:slack-star')
module.exports = (robot) ->
@shokai
shokai / ux_1000yen.coffee
Last active August 29, 2015 14:09
hubot script UX1000円
# Description:
# UXと言われたら1000円と返す
#
# Author:
# @shokai
module.exports = (robot) ->
reply = (msg) ->