This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 = {} | |
h1.default= [] | |
h1[:a] = h1[:a] << "hi" | |
h1[:b] = h1[:b] << "ho" | |
p h1 #=> {:a=>["hi", "ho"], :b=>["hi", "ho"]} | |
h2 = {} | |
h2.default_proc = ->(hash, key){ [] } | |
h2[:a] = h2[:a] << "hi" | |
h2[:b] = h2[:b] << "ho" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'smalrubot' | |
board = Smalrubot::Board.new(Smalrubot::TxRx::Serial.new) | |
100.times do | |
p board.analog_read(0) | |
sleep 1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
p self #=> Foo (Fooクラス) | |
@bar = "hello!" | |
def foo | |
p self #=> #<Foo:0x007ff63a2471f0> (Fooクラスインスタンス) | |
p @bar = "hi!" | |
end | |
def self.foo | |
p self #=> Foo (Fooクラス) | |
p @bar #=> "hello!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h = {} | |
["a", "a", "b"].each do |x| | |
h[x] = [] unless h[x] | |
h[x] << x | |
end | |
p h | |
#=> {"a"=>["a", "a"], "b"=>["b"]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# routesの中でrequest_specで呼ばれないエンドポイントを探す | |
require "active_support" | |
require "active_support/core_ext" | |
require "awesome_print" | |
### routes | |
raw_routes_string = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes).format(ActionDispatch::Routing::ConsoleFormatter.new) | |
raw_routes = raw_routes_string.split("\n") | |
raw_routes.shift # 先頭行はヘッダ行なので読み飛ばし | |
routes = raw_routes.map do |line| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input="ja 東京都 80 0" | |
data=input.split | |
output={domain:data[0],title:data[1],access_count:data[2]} | |
p output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# https://github.com/masutaka/compare_linker | |
# 使い方 | |
# bundle updateします | |
# コミット、プッシュしてPR作ります | |
# このファイルにPR番号やアクセストークンを書くか、実行時に以下のように指定します。 | |
# $ PR_NUMBER=7777 OCTOKIT_ACCESS_TOKEN=xxxxxx bin/compare_linker | |
# PRにコメントが投稿されてます | |
require 'bundler/setup' | |
require 'compare_linker' |
WindowsでRails環境を作る方法です。Rails Installerを使う方法と、zipファイルを展開する方法のどちらかを選んでください。