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...

...with more than one developer should always consider to enforce code review even for small changes to improves the overall code health of the system. Here are some guidelines that...

...perfect pull request Google Google's Engineering Practices documentation Modern Code Review: A Case Study at Google Thoughtbot Thoughtbot' Code Review Guideline

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...

...Open-source software (OSS) is great. Anyone can use virtually any open-source code in their projects." Well, it depends. Licenses can make things difficult, especially when you are developing...

...gem by following these steps: Move all contents of vendor/asset-libs/$library-$version to a new sub-directory vendor/asset-libs/$library-$version/lib/assets/javascripts. That's simply a path sprockets will consider, it is...

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

track down warnings and to see failing specs immediately or to get an overview of the core functionalities, you can use RSpec's "nested" format. It looks...

Tool validations should require model to be set should require place_id to be set #identifier should include the model and tag if the tool has a tag...

...ve built a few gems over the years. Some of these are quite popular: spreewald (> 1M downloads), active_type (> 1M downloads), and geordi (> 200k downloads) Developing a Ruby gem is...

...Rails applications, with the biggest difference: there is no Rails. This means: no defined structure (neither for code nor directories) no autoloading of classes, i.e. you need to require all...

...Chrome to check if the problem disappears. Keep in mind though that running outdated software, especially web browsers, is in most cases not a good idea. Please verify periodically if...

...you still need to run the old version or if an even more recently updated version fixes the problems introduced in your version. Here's how to get old versions...

...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...

umaar.com

Similar to the Webpack Bundle Analyzer, Chrome's new Lighthouse feature … … shows a visualisation of your JavaScript bundles. It's compatible with sourcemaps and is great for understanding large JavaScript...

...in development. It also works on production code, where its usefulness depends on the structure of the productive Javascript code. Warning This will only work when your bundler emits source...

...binary file. This method might be telling the truth most of the time. But sometimes it doesn't, and that's what causes pain. The method is defined as follows...

...not guaranteed to be 100% accurate. It performs a "best guess" based # on a simple test of the first +File.blksize+ characters. # # Example: # # File.binary?('somefile.exe') # => true # File.binary?('somefile.txt') # => false #--

Orca is a Linux screen reader. Since it is part of the GNOME project it should come preinstalled with Ubuntu installations. Getting started To turn on the screen reader you...

...can either go to Settings > Accessibility and then activate Screen Reader in the "Seeing" section or you can simply type orca in your terminal. Alternatively you can use the default...

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

...that is responsible for some (unexpected) behavior. You can use DOM Breakpoints for debugging subtree modifications, attribute modifications or node removal. Here you can see a very simple example that...

...shows what JavaScript lines are responsible for a text change (subtree modification): You can use this Code Pen if you want to try it yourself...

...partial template. # _weather.html.erb The weather is <%= condition %> # index.html.erb render partial: 'weather', locals: { condition: 'good' } Since this is a common use-case, there's a shorthand way of rendering the partial...

...Notice that it's not possible to mix the explicit partial: 'template' and the shorthand arguments for defining local variables. So either use longform variant or the shorthand variant, but...

In a nutshell: return statements inside blocks cause a method's return value to change. This is by design (and probably not even new to you, see below) -- but can...

...a problem, for example for the capture method of Rails. Consider these methods: def stuff puts 'yielding...' yield puts 'yielded.' true end We can call our stuff method with a...

api.rubyonrails.org

When working with file uploads, we sometimes need to process intrinsic properties like the page count or page dimensions of PDF files. Retrieving those properties requires us to download (from...

...a blob, as it could leak across different contexts. Ad-hoc Metadata Caching For isolated, single-use requirements, you can write directly to the blob's metadata hash. This evaluates...

github.com

Maintenance mode is enabled on application server as soon as the file /public/system/maintenance.html is present. Note that the servers must be configured accordingly. Installation Add this line to your...

...application's web interface by writing a #{maintenance_basename}.html file to each web server. By default, the maintenance page will just say the site is down for "maintenance", and...

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...

In a Jasmine spec you want to spy on a function that is imported by the code under test. This card explores various methods to achieve this. Example

...a function hello(): // lib.js function hello() { console.log("hi world") } export hello We have a second module 'client' that exports a function helloTwice(). All this does is call hello() two times...

makandra dev

...Capybara will wait for a short time before raising NoSuchElementError. This is sufficient for basic, server-rendered application. However, as frontends become more complex (more JavaScript, AJAX requests, animations), race...

...scrolling by default. You can address this by disabling smooth scrolling in tests: body, html { scroll-behavior: auto !important; } If you have other scrolling elements with overflow-y: scroll or...

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...

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...

kukicola.io

Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals or additional database columns required...