エンジニアのソフトウェア的愛情

または私は如何にして心配するのを止めてプログラムを・愛する・ようになったか

2016-04-01から1ヶ月間の記事一覧

Config

GitHub - railsconfig/config: Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other Ruby projects. Gemfile gem 'config' install $ be rails g config:install create config/initializers/config.rb create confi…

SettingsLogic

GitHub - binarylogic/settingslogic: A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern. Gemfile に追加する。 gem 'settingslogic' config/initializers/settings.rb ファイルを追加す…

特定のモジュールをインクルードしているクラスを抽出する

探せばもっとよい方法があるかもしれない。 module Hoge def hoge puts "I'm #{self.class}. I'm including Hoge." end end class Foo include Hoge end class Bar include Hoge end class Baz < Bar end ObjectSpace.each_object(Class).select {|klass| kl…

read CSV file

備忘録。 # CP932 から UTF-8 に変換し、先頭行をヘッダとして読み込む CSV.foreach(csv_file_path, encoding: 'CP932:UTF-8', headers: true) do |row| p row # 行を Hash で欲しい場合 # p row.to_hash end