robots.thoughtbot.com

...how to make fixes in other people's GitHub repositories. It's basically "Open Source Development 101". Way back in mid-2007, when Rails 1.2 was the new hotness and...

...GitHub was still a year away from crawling out of the primordial internet soup, prolific open source contributor Dr Nic wrote an article titled “8 steps for fixing other people...

The terraform documentation states the...

...syntax as (grouping mode*. See: Grouping-Results). But this seems not the be the whole truth. Instead the...

...syntax behaves like Go's Ellipsis expression...

...is only available for for expressions. This can be especially useful when creating data structures in loops: users = { users = { "Bob.Bobster" = { name = { given_name = "Bob" family_name = "Bobster" } email = "bob.bobster@foobaringen.com"

SimpleForm is a great approach to simplifying your forms, and it comes with lots of well-defined input types. However, the :grouped_select type seems to be overly complicated for...

Consider this example, from the documentation: form.input :country_id, collection: @continents, as: :grouped_select, group_method: :countries While that looks easy enough at a first glance, look closer. The...

edgeapi.rubyonrails.org

The linked article suggests an interesting way to speed up tests of Rails + Postgres apps: PostgreSQL allows the creation of “unlogged” tables, which do not record data in the PostgreSQL...

...Write-Ahead Log. This can make the tables faster, but significantly increases the risk of data loss if the database crashes. As a result, this should not be used in...

These two addons will change your life: Search as list This will always open search results in the list views instead of the barely usabely faceted search view.

...results by date not relevance Does what it says...

...an element's attributes in Capybara. A few examples: find('#my_element')['class'] # => "first-class second-class" find('#my_input')['placeholder'] # => "My placeholder value" find('a#example-link')['href...

By pressing Ctrl + Shift + V you can select a recently copied string for pasting...

...breakpoint tier in JavaScript, employ this CSS: :root { --current-breakpoint-tier: xs; @media (min-width: $screen-sm-min) { --current-breakpoint-tier: sm; } @media (min-width: $screen-md-min) { --current-breakpoint...

} @media (min-width: $screen-lg-min) { --current-breakpoint-tier: lg; } @media (min-width: $screen-xl-min) { --current-breakpoint-tier: xl; } @media (min-width: $screen-xxl-min) { --current-breakpoint...

...not on par with your IDE of choice. I have found that it also slows down my IRB in some cases, or that pressing the Backspace key does not always...

...annoying than useful. You may disable multi-line autocomplete by using the --nomultiline commandline switch (for Rails, use bin/rails console -- --nomultiline), or specifying IRB.conf[:USE_MULTILINE] = false in your ~/.irbrc...

Sometimes you will need an input field which wraps content and grows in height as soon as content gets longer than the input fields width. There is no way to...

...get a "normal" string input field to wrap as desired, but there are other ways. Here is one pretty easy solution to get what you want: Step 1

makandra dev
stackoverflow.com

This StackOverflow question about nested function definitions in Ruby imparts a good understanding of Ruby's def...

Use the click method on the DOM element: let link = document.querySelector('a') link.click()

codepen.io

...where elements break the layout's horizontal container width, like navigation buttons of a slider that should be at the left/right of the browser window, or simply by applying a...

...that. Like margin: 0 -10000px plus overflow-x: hidden. There is a much saner approach. Consider the following markup: Hello Let's say .container encloses its contents like so...

markodenic.com

...content for the linked article: 1. The `loading=lazy` attribute 2. Email, call, and SMS links 3. Ordered lists `start` attribute 4. The `meter` element 5. HTML Native Search...

...Fieldset Element 7. Window.opener 8. Base Element 9. Favicon cache busting 10. The `spellcheck` attribute 11. Native HTML sliders 12. HTML Accordion 13. `mark` tag 14. `download` attribute 15. Performance...

TLS/SSL certificates are often used for HTTPS traffic. Occasionally a service may also use their TLS certificate to support public-key encrypting data (e.g. when it is part of the...

...URI and visible to the user, but contains sensitive information). Here is how to easily fetch such certificate data. certificate = Net::HTTP.start('example.com', 443, use_ssl: true) { |http| http.peer_cert...

...full trace reveals that ActionPack's action_controller/integration.rb is breaking while doing this: cookies = @headers['Set-Cookie'] cookies = cookies.to_s.split("\n") unless cookies.is_a?(Array) cookies.each do |cookie| name, value = cookie.match...

...happened for me. That is how my cookie looked when debugging: (rdb:1) puts headers['Set-Cookie'] remember_token=abcdef123456; path=/; expires=Mon, 31-Dec-2029 23:03:29 GMT...

There are cases when you need to select DOM elements without jQuery, such as: when jQuery is not available when your code is is extremely performance-sensitive

...an entire HTML document (which is hard to represent as a jQuery collection). To select descendants of a vanilla DOM element (i.e. not a jQuery collection), one option is to...

github.com

The ancestry gem allows you to easily use tree structures in your Rails application. There is one somewhat unobvious pitfall to it: its way of applying the orphan_strategy which...

...might want to disallow destruction if there are any child nodes present. The restrict strategy does the trick but raises an exception when destroy is called: has_ancestry :orphan_strategy...

Ever seen this error when using Graticule? Numerical argument out of domain - acos Similarly to the to_sql problem for some edge cases, Graticule::Distance::Spherical.distance (and possibly those of...

...Graticule's other distance computation classes) is subject to Float rounding errors. This can cause the above error, when the arc cosine of something slightly more than 1.0 is to...

The will_paginate gem will show a default of 30 records per page. If you want to test pagination in a Cucumber feature, you don't want to create...

...records just for that. Instead, you probably want to modify the number of items shown, by saying something like this: Given we paginate after 2 users Using the following step...

You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...

...be that the Content-Disposition header is not set. That's why the following spreewald step might raise an error: Then I should get a download with filename "..." expected: /filename...

If you want to know your public key's fingerprint, do this: ssh-keygen -lf ~/.ssh/my.key.pub This may be necessary to authenticate your key on GitHub because of recent events...

...them (to pull etc): ERROR: Hi foobear, it's GitHub. We're doing an SSH key audit. Please visit https://github.com/settings/ssh/audit/... to approve this key so we know it...

xaprb.com

...result is mutual exclusivity that works in a distributed environment, and it’s dead simple to implement. Ruby implementation An implementation as a Rubygem seems to be with_advisory_lock...

...It has support for MySQL, PostgreSQL and SQLite. Unfortunately, it has a horrible caveat in MySQL: With MySQL (at least <= v5.5), if you ask for a different advisory lock within...

When searching for text in a MySQL table, you have two choices: The LIKE operator FULLTEXT indexes (which currently only work on MyISAM tables, but will one day work on...

...InnoDB tables. The workaround right now is to extract your search text to a separate MyISAM table, so your main table can remain InnoDB.) I always wondered how those two...