Skip to content

Instantly share code, notes, and snippets.

View hanachin's full-sized avatar
🌺
OKA

Seiei Miyagi hanachin

🌺
OKA
View GitHub Profile
@hanachin
hanachin / README.md
Last active May 19, 2019 04:42
Okinawa.rb Ruby Puzzles 2019/5/15 - #rubykaigi のRubyPuzzleが面白かったので真似しました。Ruby 2.7でしか動きません。
@hanachin
hanachin / command.md
Last active April 22, 2019 09:28
システムの時刻がUTC+09:00で18:28にテスト実行すると落ちる、タイムゾーンをUTC+00:00付近に移動すると、直る
% ruby -v
ruby 2.7.0dev (2019-04-22 trunk 67659) [x86_64-darwin18]
% git rev-parse HEAD
9a08215e790735485353bafd4f5f3053bd8333e3
% bin/rails test test/functional/issues_controller_test.rb:358 > log.txt
def match?(obj)
case obj
in [1, 2, [3, 4]]
p :match
else
p :not_match
end
end
obj1 = Object.new
@hanachin
hanachin / file0.txt
Last active May 6, 2019 09:11
Ruby 2.7の新機能メソッド参照演算子 ref: https://qiita.com/hanachin_/items/1aa1ba38a87dee91aed6
123.method(:to_s)
# => #<Method: Integer#to_s>
@hanachin
hanachin / file0.txt
Last active January 9, 2019 04:50
凸凹のRSpec平らに均すshared_contextがマジ便利 ref: https://qiita.com/hanachin_/items/fa9133c9441b63039194
RSpec.describe "動画が見れる", type: :system do
context "ログインしている場合" do
before do
ログイン
end
context "クレジットカードを登録している場合" do
before do
クレジットカードを登録する
end
@hanachin
hanachin / file0.txt
Last active December 24, 2018 15:37
Re: 10分間隔で 10時〜23時台の配列をつくる ref: https://qiita.com/hanachin_/items/1a7b9ea0af62e5021c94
("10:00".."23:50").step(10).select {|t| t.match?(/:[0-5]0/) }
@hanachin
hanachin / file0.txt
Last active December 20, 2018 07:20
Ruby 2.6のASCII以外の大文字で定義できる定数を試す ref: https://qiita.com/hanachin_/items/1db0ddfeeff43b8420dd
% ruby='𝐀=42; p defined?(𝐀)'; RBENV_VERSION=2.5.3 ruby -ve $ruby; RBENV_VERSION=2.6.0-rc2 ruby -ve $ruby;
ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-linux]
"local-variable"
ruby 2.6.0rc2 (2018-12-15 trunk 66408) [x86_64-linux]
"constant"
@hanachin
hanachin / file0.txt
Last active December 14, 2018 15:01
配列にためる手間なしenum_for ref: https://qiita.com/hanachin_/items/134000befc7f5fdce94c
def 動物API
@動物API ||= Object.new
end
def 動物API.page(page)
{
1 => ["鶏"],
2 => ["豚"],
3 => ["牛"]
}[page] || []
@hanachin
hanachin / file0.txt
Last active December 14, 2018 15:01
RubyでJavaScriptのTemplate literalsの真似をする ref: https://qiita.com/hanachin_/items/f1f822ff2ecd5f384eca
% gem i javascript_template_literals
@hanachin
hanachin / file0.txt
Last active December 13, 2018 14:34
Turnipで書いたfeatureにパスに応じて異なるtypeをつける方法 ref: https://qiita.com/hanachin_/items/e3ad66bbff4da97efafd
RSpec.configure do |config|
config.define_derived_metadata(:file_path => %r{/spec/models/.*.feature}) do |metadata|
metadata[:type] = :model
end
end