Skip to content

Instantly share code, notes, and snippets.

View kyoh86's full-sized avatar
🏠
Working from home

Kyoh kyoh86

🏠
Working from home
View GitHub Profile
@kyoh86
kyoh86 / split_command.js
Last active August 29, 2015 14:13
Split a command-line to an array
var splitCommand = (function(){
function State(text) {
this.args = [];
this.term = '';
this.quot = null;
this.next = null;
['split', 'quoted', 'interm', 'escape'].map(function(m){
this[m] = function(at){
at++;
@kyoh86
kyoh86 / kingpin.app.go
Last active October 6, 2015 04:35
kingpin.app.go
package main
import (
"os"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)
type Conf struct {
Hoge string `json:"hoge"`
@kyoh86
kyoh86 / recover.go
Last active December 1, 2015 04:06
recover and set state
func do(ctx context.Context) (res *Result) {
defer func() {
if r := recover(); r != nil {
trace := make([]byte, 1024*10)
count := runtime.Stack(trace, true)
switch tr := r.(type) {
case error:
res = &Result{
Err: tr,
@kyoh86
kyoh86 / errors.go
Last active December 1, 2015 04:22
Error aggregatable
package util
import (
"encoding/json"
"errors"
"fmt"
)
// Errors : 複数のエラーを一括するエラー
type Errors []error
@kyoh86
kyoh86 / brew-infos.sh
Created January 8, 2016 01:16
List-up applications' name and url, installed with Homebrew
brew list|grep -v '^lib' |while read line; do
echo -n ${line}$'\t'
brew info $line | grep '^http'
done | column -t -s $'\t'
package main
// Ellipsis a text
func Ellipsis(length int, text string) string {
r := []rune(text)
if len(r) > length {
return string(r[0:length]) + "..."
}
return text
}
@kyoh86
kyoh86 / file0.txt
Last active February 8, 2016 06:52
Homebrewでインストールしたあいつらを丁寧にアップデートする ref: http://qiita.com/kyoh86/items/9c9ee02177bd9da22b6c
$ brew update && brew outdated # 更新が必要なパッケージの一覧を取得、確認。
...
...
$ brew outdated \
| awk '{print $1}' \
| grep -v 'elasticsearch' \
| grep -v 'mongo' \
| xargs -n 1 brew upgrade
@kyoh86
kyoh86 / lint.sh
Created February 8, 2016 16:21
golintと闘いたいけど心の折れてしまった勇者のための隠しダンジョン ref: http://qiita.com/kyoh86/items/1f2022b63372b84f1a27
owner= # 対象リポジトリ名(オーナー名)を設定
repos= # 対象リポジトリ名を設定
min_confidence=0.9 # 警告のレベル
head=$(git rev-parse --abbrev-ref @) # 現在のブランチを取得
if [ -n "${head}" ]
then
# 現在のブランチをheadとするpull-requestを探す
base=$(gogh pr ls --repo ${owner}/${repos} --head ${owner}:${head} --state open --row-format $'{{.Base.Ref}}')
if [ -z "${base}" ]
then
@kyoh86
kyoh86 / file1.txt
Last active May 6, 2016 14:19
PHP+postfix with Gmail on El Capitan ref: http://qiita.com/kyoh86/items/c09224660da7ed618afd
[smtp.gmail.com]:587 hoge@hoge.com:hogehogehoge
say "生"~&"死"