Skip to content

Instantly share code, notes, and snippets.

View kymmt90's full-sized avatar

Kōhei Yamamoto kymmt90

View GitHub Profile
@kymmt90
kymmt90 / parse_yaml.rb
Created October 1, 2017 05:17
Append additionalProperties: false to all schemas in the OpenAPI definitions section
require 'yaml'
doc = YAML.parse(STDIN).to_ruby
doc['definitions'].transform_values! { |schema| schema.merge('additionalProperties' => false) }
puts doc.to_yaml
@kymmt90
kymmt90 / a.rb
Created October 4, 2017 16:12
watching OpenAPI docs
initializer 'watch_open_api_docs' do |app|
app.reloaders << app.config.file_watcher.new([], { Rails.root.join('open_api_docs').to_s => ['yml'] })
config.to_prepare do
yaml = YamlRefResolver.new.resolve!(Rails.root.join('open_api_docs', 'index.yml')).to_yaml
Tempfile.create do |f|
OpenApiParser::Specification.resolve!(f.path)
end
rescue JsonSchema::Error => e
Rails.logger.error e.full_message
end
package isbn;
import java.util.regex.Pattern;
/**
* ISBN class.
*/
public class Isbn {
/** Number of digits in ISBN. */
public static final int LENGTH = 13;
@kymmt90
kymmt90 / git-reflog.md
Last active December 28, 2022 11:42
`git reflog` についてまとめてみる

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

reflog とは

  • reflog(参照ログ)とは HEAD やブランチ先端の動きの履歴
    • 各個人のローカルリポジトリに存在
    • ブランチの切り替え、新たに加えられた変更のプル、履歴の書き換え、あるいは単なる新規コミットの実行などを記録
  • git reflog で HEAD の移動履歴を、git reflog <ブランチ名> でそのブランチ先端が指していたコミットの一覧を確認可能
    • HEAD@{5}: HEAD の五つ前の状態を示す