Skip to content

Instantly share code, notes, and snippets.

Mainly working in the GitHub Enterprise environment of my company

Yamamoto Kōhei kymmt90

Mainly working in the GitHub Enterprise environment of my company
View GitHub Profile
kymmt90 / a.rb
Created Oct 4, 2017
watching OpenAPI docs
View a.rb
initializer 'watch_open_api_docs' do |app|
app.reloaders <<[], { Rails.root.join('open_api_docs').to_s => ['yml'] })
config.to_prepare do
yaml =!(Rails.root.join('open_api_docs', 'index.yml')).to_yaml
Tempfile.create do |f|
rescue JsonSchema::Error => e
Rails.logger.error e.full_message
kymmt90 / parse_yaml.rb
Created Oct 1, 2017
Append additionalProperties: false to all schemas in the OpenAPI definitions section
View parse_yaml.rb
require 'yaml'
doc = YAML.parse(STDIN).to_ruby
doc['definitions'].transform_values! { |schema| schema.merge('additionalProperties' => false) }
puts doc.to_yaml
View .eslintrc
"env": {
"node" : true,
"browser" : true,
"es6": true
"ecmaFeatures" : {
"jsx": true,
"plugins": [
kymmt90 /
Last active Mar 10, 2021
`git reflog` についてまとめてみる

git reflog についてまとめてみる

reflog とは

  • reflog(参照ログ)とは HEAD やブランチ先端の動きの履歴
    • 各個人のローカルリポジトリに存在
    • ブランチの切り替え、新たに加えられた変更のプル、履歴の書き換え、あるいは単なる新規コミットの実行などを記録
  • git reflog で HEAD の移動履歴を、git reflog <ブランチ名> でそのブランチ先端が指していたコミットの一覧を確認可能
    • HEAD@{5}: HEAD の五つ前の状態を示す
kymmt90 / file.txt
Created Oct 5, 2016
curl から POST した gist
View file.txt
curl の気持ちになって gist を POST
View my_permutation.rb
def my_permutation(sequence, r = nil)
r = sequence.size if r.nil? || sequence.size < r
result = []
enumerate(sequence, r, [], result)
def enumerate(sequence, r, one_enumeration, result)
if one_enumeration.size == r
result << one_enumeration.dup
kymmt90 / kymmt_recipe.rb
Created Jul 24, 2016
2016-07-24 時点の 用 Itamae レシピ
View kymmt_recipe.rb
include_recipe 'selinux::disabled'
package 'epel-release'
package 'gcc'
package 'gcc-c++'
package 'git'
package 'libyaml-devel'
package 'nginx'
package 'openssl-devel'
package 'postgresql-contrib'
kymmt90 / dokaku.rb
Created Jul 10, 2016
Yokohama.rb #70 どう書く
View dokaku.rb
class Walker
Position =, :y)
MAP = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['i', 'j', 'k', 'l'], ['m', 'n', 'o', 'p']]
def initialize(tiles)
@current =, 0)
@previous = nil
@from = nil
@tiles = tiles.split('/').map { |l| l.split('') }
View hook_method.rb
module HookMethod
def hook_method(hook, *methods)
methods.each do |method|
orig = "#{method}_without_logging".to_sym
if instance_methods.include?(orig)
raise NameError, "#{orig} isn't a unique name"
alias_method orig, method
kymmt90 / get_access_token.rb
Created Sep 22, 2015
Get Hatena OAuth access token from Ruby
View get_access_token.rb
#!/usr/bin/env ruby
# coding: utf-8
# The MIT License (MIT)
# Copyright (c) 2015 Kohei Yamamoto
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights