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
| module PrependModule | |
| def foo | |
| 'prepend module' | |
| end | |
| end | |
| class PrependClass | |
| prepend PrependModule | |
| def foo |
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
| # "0:Ruby" "1:mruby" "2:RubyMotion" | |
| %w(Ruby mruby RubyMotion).each_with_index do |name, index| | |
| puts "#{index}:#{name}" | |
| end #=> ["Ruby", "mruby", "RubyMotion"] | |
| # "1:Ruby" "2:mruby" "3:RubyMotion" | |
| %w(Ruby mruby RubyMotion).each.with_index(1) do |name, index| | |
| puts "#{index}:#{name}" | |
| end #=> ["Ruby", "mruby", "RubyMotion"] |
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
| gem('sqlite3', group: :development) | |
| gem('thin', group: :development) | |
| gem('pg', group: :production) | |
| gem('everywhere') | |
| gem('rubocop', group: [:development, :test]) | |
| gem('brakeman', group: [:development, :test]) | |
| gem('rspec-rails', group: [:development, :test]) | |
| gem('factory_girl_rails', group: [:development, :test]) | |
| gem('database_rewinder', group: [:development, :test]) |
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 'csv' | |
| file_path = ARGV[0] | |
| CSV.foreach(file_path, encoding: 'SJIS:UTF-8') do |row| | |
| p row | |
| 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
| namespace :secret do | |
| secret_token_file = Rails.root.join('config', 'initializers', 'secret_token.rb') | |
| file secret_token_file do | |
| require 'securerandom' | |
| token = SecureRandom.hex(64) | |
| require 'active_support/core_ext/string/strip' | |
| application_name = Rails.application.class.name | |
| content = <<-EOS.strip_heredoc |
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
| foo = "hogehoge" | |
| bar = "hoge" | |
| foo.scan(/#{bar}/) # => ["hoge", "hoge"] |
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 'nokogiri' | |
| require 'open-uri' | |
| #ATND API Reference -> http://atnd.org/doc/api.html | |
| #Search "Pronama" events. | |
| xml_doc = Nokogiri::XML(open("http://api.atnd.org/events/?keyword=pronama&format=xml")) | |
| #Get titles | |
| xml_doc.search("//title").each do |title| | |
| puts title.text |
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 'net/https' | |
| Net::HTTP.version_1_2 | |
| http = Net::HTTP.new('www.qiita.com', 443) | |
| http.use_ssl = true | |
| http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| #twittername or githubname@github |
NewerOlder