...method to automatically compute an ETag from the given record, array of records or scope of records: class UsersController < ApplicationController def show @user = User.find(params[:id]) fresh_when @user

...by passing an array of ETaggable objects to fresh_when. class UsersController < ApplicationController def show @user = User.find(params[:id]) # The show template also renders the user's posts. fresh_when...

A severe bug was found in ImageMagick by Bryan Gonzalez from Ocelot Team. It allows to embed the content of an arbitrary remote file when ImageMagick parses PNG files.

...on updated Packages for Ubuntu (https://ubuntu.com/security/CVE-2022-44268). Due to that we patched our systems as follows: Ubuntu 22.04: Get package source on a Ubuntu 22.04 system: apt-get source...

...gem like accept_language. Customizing Rails error messages for models and attributes Rails I18n scope for humanized attribute names HTML: Making browsers wrap long words Use the same translations for...

...I18n fallback locales Rails: Including HTML in your i18n locales Even for a single language, locales are useful Even if your application only supports a single language, it makes sense...

Static error pages To add a few basic styles to the default error pages in Rails, just edit the default templates in public, e.g. public/404.html. A limitation to these default...

...templates is that they're just static files. You cannot use Haml, Rails helpers or your application layout here. If you need Rails to render your error pages, you need...

Take a look at the following material: World's shortest UI/UX design course Every UI/UX Concept Explained In Under 10 Minutes Easiest Way to Pick UI Colors

...Rules for Creating Gorgeous UI (Part 2) Visual design rules you can safely follow every time Bootstrapping Design (in our library) Steve Schoger's Refactoring UI book (in our library...

...that matter) will not be affected by this. If you define them in your specs, they will exist globally. This is because of how RSpec works (short story: instance_eval...

# ... end let(:record) { TestRecord.new }

end # TestRecord will exist here, outside of the spec! Do not do this. It will bite you eventually. For example, when you try to...

To make CSS rules dependent on the screen size, we use media queries: @media (max-width: 500px) { // rules for screen widths of 500px or smaller } Browsers will automatically enable and...

...disable the conditional rules as the screen width changes. To detect responsive breakpoints from JavaScript, you may use the global matchMedia() function. It is supported in all browsers:

I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method on Enumerable that combines the three: module Enumerable

group_by(&block) .transform_values(&:count) .sort_by(&:last) .to_h end end Just paste that snippet into a Rails console and use #count_by now! Usage examples...

...is a gem for working with daytimes. That's a tuple of (hour, minute second) without a day, month or year. Another additional gem? Thus SQL has a time datatype...

...for storing time of day in the format hh:mm:ss, neither Ruby nor Rails themselves offer an elegant way to deal with day times. Time and DateTime both handle...

...for DOM elements, there are some footguns you should know about. Some lists are synchronized with the DOM Some DOM APIs return live lists that automagically update their contents as...

...reflects the change automatically: document.querySelector('#two').remove() console.log(liveList) // [#one] console.log(nonLiveList) // [#one, #two] Snapshotting a live list Lists that silently change their elements can be very surprising to work...

...chapters from The Pragmatic Programmer, anniversary edition (in our library): Chapter 1, Topic 3: Software Entropy Chapter 2, Topic 9: The Evils of Duplication Chapter 2, Topic 10: Orthogonality

...Chapter 5: Formatting Chapter 8: Boundaries Chapter 10: Classes Chapter 12: Emergence Chapter 17: Smells and Heuristics Also read: How to write modular code Keep It DRY, Shy, and Tell...

When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc. It may be a good idea to wait for all in-flight...

...AJAX requests to finish before ending a scenario: You may have client-side JavaScript that freaks out when the tab closure kills their pending requests. If that JavaScript opens an...

...command-line tool for REPL (Read Eval Print Loop). Type gem help info to see a list of available switches. Note that the Ruby API offers a bit more insight...

...Gem Ruby API (at runtime) First, get the Gem::Specification of the gem you are looking for. That object holds all the information from the gem's gemspec file, and...

You have uncommited changes (you can always check by using git status), which you want to discard. Context Now there are several options to discard these depending on...

...your exact situation. The headlines will differentiate the cases whether the files are staged or unstaged. Staged and unstaged changes Staged changes Unstaged Changes Staged and unstaged changes

If you are using our opscomplete.com hosting we can set all environment variables mentioned below for your deployment on request. If you're lucky DO_NOT_TRACK=1 opts...

...are collecting data only after you opt into that. ng analytics --global disable Storybook https://storybook.js.org/docs/configure/telemetry npm run storybook -- --disable-telemetry npm run storybook -- --disable-crash-reports export STORYBOOK...

makandra dev

min-width is known as a CSS property that can be set to define a least width for an element. Surprisingly, it can also be used to set something that...

...it is more like "auto". This can make block elements take up much more space than desired, even stretching their container beyond the screen edge on small screens.

...in licensing, we cannot provide Elasticsearch versions >= 8.0. Version 7.17.x will reach EOL status with the release of Elasticsearch version 9. We have decided to use OpenSearch as a...

...replacement, since it is a fork of Elasticsearch version 7.10.2, still running under the previous licensing model and wire-compatible. A more detailed reasoning can be found on their website...

...a MacBook that uses an M1 or M2 Chip. Documentation on the Internet is sparse and not even the Geniuses at the Genius Bar are 100% sure. We found out...

...your MacBook, using more than one external display is only possible with workarounds. Docking stations Whenever you're considering using more than 1 external display, it makes sense to consider...

When you're using feature branches, they will stack up if you don't delete them after the merge to master. Here's how to tidy them up. Delete feature...

...Find already-merged branches by running # On branch master git branch --merged You may safely delete each of the listed branches, because they point to commits that are contained in...

...always is to prevent long-running queries in the first place, automatic timeouts can serve as a safety net to terminate problematic queries automatically if a set time limit is...

...statement due to statement timeout (PG::QueryCanceled)). If multiple SQL statements appear in a single simple-query message, the timeout is applied to each statement separately. Set the timeout globally...

When you find similar groups of expect calls in your tests, you can improve readability by extracting the group into its own matcher. RSpec makes this easy by allowing matchers...

We can extract the repeated matcher chains into a custom matcher called be_shouting: expect(foo).to be_shouting expect(bar).to be_shouting Instead of re-implementing the...

When a user shares your content, a snippet with title, image, link and description appears in her timeline. By default social networks will use the window title, the first image...

...the current URL and some random text snippet for this purpose. This is often not what you want. Luckily Facebook, Twitter, etc. lets you control how your content appears in...

When you create a temporary file (e.g. to store a generated Excel sheet) and try to send it to the browser from a controller, it won't work by default...

...this controller action: class FoosController < ApplicationController def download file = Tempfile.new('foo') file.puts 'foo' file.close send_file file.path end end Accessing this controller action will usually raise a 404 not found...

Applications often show or hide elements based on viewport dimensions, or may have components that behave differently (like mobile vs desktop navigation menus). Since you want your integration tests to...

...behave consistently, you want to set a specific size for your tests' browser windows. Using WebDriver options / Chrome device metrics For Google Chrome, the preferred way is setting "device metrics...