...optimize the experience. Using capistrano-rails capistrano-rails is a Gem that adds Rails specifics to Capistrano, i.e. support for Bundler, assets, and migrations. While it is designed for Asset...

...Pipeline (Sprockets) assets, it can easily be configured for Webpacker. This brings these features to the Webpacker world: Automatic removal of expired assets Manifest backups # config/deploy.rb # No need to include...

to create a Gallery that has a name and has_many :images, which in turn have a caption to offer the user a single form to create...

...with any number of images immediate uploads with a progress bar per image a snappy UI Enter jQuery File Upload. It's a mature library that can do the job...

When you need to see the content of a page (i.e. not all the HTML but the relevant text body) you can do pp (html_content) pp will format the...

...html String human readable pretty printed where html_content can be replaced by one of the following commands: Rails body or response.body Capybara: page.driver.html.content page.body Webrat: Nokogiri::HTML(response.body).content...

...Layouts tab you have handy options to debug CSS Flexbox and Grid. Including: Display size and lines along with labels Changing their attributes Change how overlay is colored and fastly...

...switch nested elements in the Elements panel This guide will only cover some example gif recordings on how to use with Grid, since it's basically straight forward to apply...

Rails comes with a Rake task notes that shows code comments that start with "TODO", "FIXME", or "OPTIMIZE". While it's generally not good practice to leave them in your...

...not yet available. To keep track of them, run rake notes. Its output looks something like this: $ rake notes app/controllers/frontend/media_documents_controller.rb: * [ 6] [TODO] should be part of a publication workflow app/helpers/frontend/slider_helper.rb...

...don't only have a favicon.ico in your project but also PNGs of different sizes and backgrounds, you should test if all those files are actually reachable.

...few selectors to get you started: 'link[rel~="icon"]' # regular ones, matches "shortcut icon" and "icon" 'link[rel="apple-touch-icon"]' # iOS 'meta[content][name="msapplication-TileImage"]' # IE11 'meta[content...

...modern JavaScript down to EcmaScript 5. Depending on what browser a project needs to support, the final Webpack output needs to be different. E.g. when we need to support IE11...

...JavaScript features. Hence our output will be more verbose than when we only need support modern browsers. Rails 5.1+ projects often use Webpacker to preconfigure the Webpack pipeline for us...

...some beyond 50MB. Unless you need to offer this large files, you should always shrink uploaded files to a reasonable resolution. class ImageUploader < CarrierWave::Uploader::Base process resize_to_limit...

When you do a bitwise copy using the dd tool you will not see any output until it completes or an error occurs. However, you can send a command signal...

...to the process to have it show its progress so far. From another terminal, simply call (be root or use sudo): pkill -USR1 dd This makes dd write something like...

In Cucumber, scenario outlines help avoiding tests that are basically the same, except for a few variables (such as different inputs). So far, nothing new. The problem

...your test should (or should not) do something, like filling in a field only for some tests? Scenario Outline: ... When I open the form And I fill in "Name" with...

github.com

...GitHub repository is a bit like our "dev" cards deck, but groomed from a single person (Josh Branchaud). It includes an extensive list of over 900 TILs on many topics...

...TILs that were new to me. I encourage you to take your time to skim over the original list as well! Assoc For Hashes Hash#assoc can be used to...

...a remote API, check out the VCR gem as an alternative to Webmock or stubbing hell. The idea behind VCR is that is performs real HTTP requests and logs the...

...in a .yml file. When you run the test again, requests and responses are stubbed from the log and the test can run offline. It's a great way to...

When you need to store structured data (like Ruby hashes) in a single database column with ActiveRecord, a simple way is to use PostgreSQL's jsonb columns. ActiveRecord will automatically...

...serialize and deserialize your Hash to and from JSON, and you can index JSON paths for fast reads. As an alternative, ActiveRecord::Store offers a way to store hashes in...

makandra dev

...to do it. Make an educated decision: Is the code change worth the effort? Stay straight on track, don't go astray. Note: Usually, you'd refactor after finishing your...

...story. At times, it might be necessary to refactor up front. But try to keep refactoring out of your current task. Knowing where to optimize Things should only be optimized...

makandra dev

I recently did a quick research on how to better write down multiline statements like this: # Dockerfile RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ && apt-get dist-upgrade -y...

...apt-get install --no-install-recommends --no-install-suggests -y \ ca-certificates \ curl \ unzip It turns out, there is! Buildkit, the tool behind docker build added support for heredoc strings...

Boot partitions from installations prior to the 16.04 era are terribly small. When you install updates and encounter errors due to a full /boot partition, consider risizing it.

...can't do the steps described below, ask someone experienced to help you out. This has worked 100% so far. 1 out of 1 tries. ;) Scenario A: There is unassigned...

makandra dev
github.com

If you want to build a small CLI application, that supports more advanced inputs than gets, I recommend using the cli-ui gem. It's a small dependency-free library...

...that provides basic building blocks, like an interactive prompt: require "cli/ui" CLI::UI::StdoutRouter.enable puts CLI::UI.fmt "a small {{red:demo}}" # supports h, j, k, l, arrows and even filtering...

In Rails 3.1+, instead of defining a separate up and down method you can define a single method change: class AddComparisonFieldsToReport < ActiveRecord::Migration def change add_column :reports, :compare, :boolean...

...update "UPDATE reports SET compare = #{quoted_false}" add_column :reports, :compare_start_date, :date add_column :reports, :compare_end_date, :date end end Migrating up works as expected:

To update your Rubygems to the latest available version, type the following: gem update --system Note that you have a separate Rubygems installation for each Ruby version in your RVM...

...or rbenv setup. Updating one does not update the others. Ruby 1.8.7 If you are using Ruby 1.8.7 you cannot use the latest version of Rubygems. Type the following to...

developer.mozilla.org

Container queries enable you to apply styles to an element based on the size of the element's container. If, for example, a container has less space available in the...

...surrounding context, you can hide certain elements or use smaller fonts. Container queries are an alternative to media queries, which apply styles to elements based on viewport size or other...

In Rubocop you might notice the cop Style/CaseEquality for e.g. this example: def foo(expected, actual) expected === actual end In case expected is a Regex, it suggests to change it...

...foo(expected, actual) expected.match?(actual) end In case expected is a Regex or a String, you need to keep ===. Otherwise the actual expression is always converted to a regular expression...

...messages should include the ID of the issue your code belongs to. Our preferred syntax prefixes the issue title with its ID in brackets, e.g. [FOO-123] Avatars for users...

...When I go to the dashboard And console Then I should see "Hans Peter" AfterStep @slow-motion Waits 2 seconds after each step Example: @slow-motion Given there is a...

When I go to the dashboard Then I should see "Hans Peter" AfterStep @single-step Waits for a keypress after each step Example: @single-step Given there is...

...with modern CSS features In the past, you might have resorted to bulky JavaScript solutions or CSS hacks like transitioning between max-height: 0 and max-height: 9999px. All of...

...them were awkward and/or have several edge cases. With modern CSS, there is actually a way to do it properly: Just use a display: grid container which transitions its grid...