Enumerable#all? returns true for an empty collection. This totally makes sense but you have to think about it when...
This article will show you how to use throw and catch. It's a nice tool to break out of...
Rails applications and ruby gems should have a README that gives the reader a quick overview of the project. Its...
When writing XLSX files, there are gems like rubyXL or axlsx. While they do offer features like formatting or graphs...
PostgreSQL supports the SQL OVERLAPS operator. You can use it to test if two date ranges overlap: => SELECT ('2001-02...
Summary: Don't add chromedriver-helper to the Gemfile the executables might break your tests in projects where chromedriver-helper...
A common pattern in Ruby is to to require all files in a specific diretory, using something like Dir.glob(Rails.root.join...
Checking if a JavaScript value is of a given type can be very confusing: There are two operators typeof and...
If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it.
An end-to-end test (E2E test) is a script that remote-controls a web browser with tools like Selenium...
Slides for Henning's talk on Sep 21st 2017. Understanding sync vs. async control flow Talking to synchronous (or "blocking...
Download the dictionary from http://www.winedt.org/dict.html, e.g. http://www.winedt.org/dict/de_neu.zip unzip de_neu.zip mkdir ~/Documents/dic iconv -f UTF-16 -t...
RSpec allows defining methods inside describe/context blocks which will only exist inside them. However, classes (or any constants, for that...
There are several gems that make it easy to read and process xlsx files. Parsing the entire file at once...
Use return to return from a method. return accepts a value that will be the return value of the...
I frequently find myself needing a combination of group_by, count and sort for quick statistics. Here's a method...
Scope is all about where something is visible. It’s all about what (variables, constants, methods) is available to you...
You can use local copies of gems in your Gemfile like this: gem 'spreewald', path: '~/gems/spreewald' As soon as you...
In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This...
I often see the use of || to set a default value for a variable that might be nil, null or...
ActiveRecord::RecordNotFound errors provide quite meaningful error messages that can provide some insight on application details. Consider the following:
This card will show you a cool way to define a class using Struct.new. A common usecase for Structs are...
Rails supports time zones, but there are several pitfalls. Most importantly because Time.now and Time.current are completely different things and...
Ruby's standard library is in the process of being gemified. It will soon - Ruby 2.5 - consist of RubyGems, which...