Problem Solving for Developers
A selection of problem solving resources that can be helpful for developers.
A selection of problem solving resources that can be helpful for developers.
Get on all fours and slowly move back and forth from a downward spinal curve with the head looking up like a cat and then move into a rounded spine while the head looks down like a camel. Each cycle should take about three to four seconds. 7-8 cycles are all that is needed.
Gist: Only do 7-8 cycles. More than that could be bad.
sample_input = "<div>Hi </div>"
parsed_input = Nokogiri::HTML.parse(sample_input).text #=> "Hi "
parsed_input.gsub(/\p{Space}*\z/, "") #=> "Hi"
\p{Space}
catches any whitespace character.
# We need to use 'remote_<object>_url' as attribute instead of '<object>'. | |
# Having Image, we would use 'remote_image_url: <url>'. | |
titles = [Faker::RockBand.name, Faker::BossaNova.artist, Faker::Book.title] | |
54.times do |n| | |
start_date = Faker::Date.between(1.day.from_now, 6.months.from_now) | |
end_date = start_date + 1.day | |
Event.create!(title: titles.sample + " ##{n}", |
We have a _user
partial that we want to render from two different resources, passing a collection.
The only thing that needs to change in the partial is the path inside the link_to
helper.
We can use self.send("path", object)
inside link_to
to achieve this.
By adding the spellcheck="true"
HTML attribute to any text field, browsers will automatically check for spelling errors.
<p contenteditable spellcheck="true">This exampull will be checkd fur spellung when you try to edit it.</p>
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck
Freezing the initializer after passing the args to super
makes the object immutable.
# frozen_string_literal: true
# Freezing the initializer after passing the args to `super` makes the object immutable.
#
# Example:
Adding a .slugignore
file to the root folder of the project will make Heroku to remove the files and folders referenced after we push code to Heroku and the buildpack runs.
A compressed copy of the application comprising all files in the git repo along with packages installed during deployment.
> " mary-joe o'donnell ".downcase.gsub(/\b([a-z])/) { Regexp.last_match(1).capitalize }.strip
=> "Mary-Joe O'Donnell"
Source:
We can do so by adding an array value to the param:
params.permit(:email, :name, sites: [])
We can even use nested arrays: