Christophe Philemotte, Paris.rb, 6 May 2013
Developer (@toch on GitHub, @_toch on Twitter)
Author on blog.8thcolor.com
CoFounder of PullReview https://pullreview.com
I hope to see Ruby help every programmer in the world to be productive, and to
enjoy programming, and to be happy. That is the primary purpose of Ruby
language. Matz, 2008
contacts = %w[Granny Bill]
contacts << 'Granny' unless contacts.include? 'Granny'
tags_post1 = [ 'ruby', 'rails', 'test' ]
tags_post2 = [ 'test', 'rspec' ]
common_tags = []
tags_post1.each { |tag| common_tags << tag if tags_post2.include? tag }
keyword = 'Kurt Gödel'
keyword = 'Kurt Gödel'
keyword.tr(
"ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz"
)
keyword = 'Kurt Gödel'
require 'active_support/inflector' # not necessary if Rails
ActiveSupport::Inflector.transliterate('Kurt Gödel')
specific rules into locales/de.yml
i18n:
transliterate:
rule:
ü: "ue"
ö: "oe"
ArgumentError: invalid byte sequence in UTF-8
line = "This is an invalid byte sequence \244"
line.upcase
ArgumentError: invalid byte sequence in UTF-8
line = "This is an invalid byte sequence \244"
line.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')
line.upcase
line = "This is an invalid byte sequence \244"
line.scrub!('') # gem 'string-scrub' if < 2.1
line.upcase
contacts = %w[Granny Bill]
contacts << 'Granny' unless contacts.include? 'Granny'
contacts = %w[Granny Bill]
contacts << 'Granny'
contacts.uniq!
require 'set'
contacts = Set.new(%w[Granny Bill])
contacts << 'Granny'
tags_post1 = [ 'ruby', 'rails', 'test' ]
tags_post2 = [ 'test', 'rspec' ]
common_tags = []
tags_post1.each { |tag| common_tags << tag if tags_post2.include? tag }
tags_post1 = [ 'ruby', 'rails', 'test' ]
tags_post2 = [ 'test', 'rspec' ]
common_tags = tags_post1 & tags_post2
histogram = {
monday: 5,
tuesday: 7,
wednesday: 10,
thursday: 18,
friday: 7,
saturday: 2,
sunday: 0
}
histogram = histogram.select { |k, _| k != :saturday && k != :sunday }
def filter(hsh, *keys)
hsh.select { |k, _| !keys.include? k }
end
filter(histogram, :saturday, :sunday)
def filter(hsh, *keys)
hsh.reject { |k, _| keys.include? k }
end
filter(histogram, :saturday, :sunday)
require 'active_support/core_ext/hash' # not necessary if Rails
histogram.except(:saturday, :sunday)
entries = {
1372284000 => "CVE-2013-4073",
1368482400 => "CVE-2013-2065"
}
updated_entries = {
1385074800 => "CVE-2013-4164",
1372284000 => "CVE-2013-4073",
1368482400 => "CVE-2013-2065"
}
new_entries = updated_entries.reject { |k, _| entries.include? k }
Ruby Doc http://ruby-doc.org/
Rails Doc http://api.rubyonrails.org/
Apidock http://apidock.com/
OmniRef https://www.omniref.com/
Gem source
Rails source https://github.com/rails/rails
Your coworker/colleague
A friend
ME :)