This file contains 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
# case1 | |
Hash.new.tap do |hash| | |
hash[:key1] = value1 if condition_1 | |
hash[:key2] = value2 if condition_2 | |
end | |
# case2 | |
hash = {} | |
hash[:key1] = value1 | |
hash[:key2] = value2 if condition_2 |
This file contains 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
def digits_after_decimal_point(val) | |
return unless val.is_a?(Numeric) | |
digits = 0 | |
while(val != val.to_i) | |
digits += 1 | |
val *= 10 | |
end | |
digits | |
end |
This file contains 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
version: 2 | |
jobs: | |
build: | |
working_directory: ~/my-app | |
docker: | |
- image: circleci/ruby:2.6.3-node-browsers | |
environment: | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
DATABASE_URL: postgres://postgres:password@localhost:5432/tech_cast_test |
This file contains 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 DropUsers < ActiveRecord::Migration | |
def change | |
drop_table :users do |t| | |
t.string :name, null: false | |
t.string :email, null: false, unique: true | |
t.timestamps null: false | |
end | |
end | |
end |
This file contains 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
%body | |
- flash.each do |key, value| | |
- key = "info" if key == "notice" | |
- key = "danger" if key == "alert" | |
= content_tag :div, value, class: "alert alert-#{key}" |
This file contains 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
<% link_to root_path do %> | |
<i class="icon-home"></i> ホーム | |
<% end %> |
This file contains 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
# ローカルのmasterブランチ以外削除 | |
$ git branch | grep -v 'master' | grep -v '*' | xargs git branch -D | |
# リモートのmasterブランチ以外全削除 | |
$ git branch -r | grep origin | grep -v master | sed -e s/^.*origin\\///g | xargs git push -d origin |
This file contains 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
prefectures = %w(北海道 青森県 岩手県 宮城県 秋田県 山形県 福島県 茨城県 栃木県 群馬県 埼玉県 千葉県 東京都 神奈川県 新潟県 富山県 石川県 福井県 山梨県 長野県 岐阜県 静岡県 愛知県 三重県 滋賀県 京都府 大阪府 兵庫県 奈良県 和歌山県 鳥取県 島根県 岡山県 広島県 山口県 徳島県 香川県 愛媛県 高知県 福岡県 佐賀県 長崎県 熊本県 大分県 宮崎県 鹿児島県 沖縄県) |
This file contains 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
# | |
# 数字 | |
# | |
# 全て数値(全角) | |
/\A[0-9]+\z/ | |
# 全て数値(半角) | |
/\A[0-9]+\z/ |
This file contains 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
<%= button_tag, class: "btn btn-default btn-sm" do %> | |
<%= content_tag :span, "送信", class: "glyphicon glyphicon-star" %> | |
<% end %> |
NewerOlder