Skip to content

Instantly share code, notes, and snippets.

View ota42y's full-sized avatar

ota42y ota42y

View GitHub Profile
@ota42y
ota42y / levenshtein_distance.rb
Created July 19, 2015 13:08
Levenshtein distance
# coding: utf-8
def get_cost(d, c1, x, c2, y)
costs = []
if c1 == c2
# 同じ場合
costs << d[y-1][x-1]
end
if c1 != c2
package main
import (
"fmt"
"net/http"
)
// localhost:8080/ retrun exec folder
// localhost:8088/.... return same name file
// localhost:8080/handler return url path(from handler function)
@ota42y
ota42y / wl_report.go
Created December 7, 2015 22:56
wl_report
/*
Usage:
# get https://github.com/robdimsdale/wl
go get -u github.com/robdimsdale/wl
# set up wunderlist setting for wl
go build report.go
wl tasks --completed true -j | ./report
2015-11-30 10 tasks completed
begin
require "bundler/inline"
rescue LoadError => e
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "activesupport"
end
def badName(test)
puts test and false
end
badName(42)
git diff -z — name-only origin/master | xargs -0 bundle exec rubocop-select | xargs bundle exec rubocop — require rubocop/formatter/checkstyle_formatter — format RuboCop::Formatter::CheckstyleFormatter | RUBYOPT=-EUTF-8 bundle exec checkstyle_filter-git diff origin/master | RUBYOPT=-EUTF-8 bundle exec saddler report — require saddler/reporter/github — reporter Saddler::Reporter::Github::PullRequestReviewComment
# 環境変数GITHUB_TOKENの設定が必要
# LABEL_NAMEに設定した名前のラベルをIssueに付けて作成する
# Issueの名前はrubocopのルールの名前と完全に一致する
# old_rubocop_rule.ymlの中に同じルールがあった場合はその内容をbodyに加える
require 'yaml'
require 'octokit'
LABEL_NAME = 'rubocop-auto-config'
# 環境変数GITHUB_TOKENの設定が必要
# todo_labelに設定したラベルが付いているIssueを調べ、
# auto_corrected_labelが付いていないものに対して`rubocop -auto_correct`を実行して結果をPull Requestにする
# 前提条件
# - Issueのタイトルがrubocopの設定名と完全に一致している
# - repo_local_pathフォルダにgit cloneしてある
# - repo_base_branchに設定したブランチが存在する
# - git pushができる
require "open3"
@ota42y
ota42y / 0_result_with_hash.rb
Last active December 21, 2017 09:48
result_with_hash
require "erb"
erb_obj = ERB.new("<%=name%> \"Hello <%=first_name%> <%=last_name%>!\"")
name = 'honoka'
last_name = 'kousaka'
puts erb_obj.result_with_hash(first_name: 'kotori', last_name: 'minami')
puts "Top level name is #{name}, #{last_name}"