tl;dr Individual transform properties are great because they allow you to write more readable and maintainable CSS, especially when...

JavaScript is a scripting language supported by all browsers. Browsers don't speak Ruby, so if we want to implement...

regular-expressions.info

Look-arounds provide a way to match context-dependant. You can look-behind, look-ahead and to both in a positive and negative way. The look-around will...

...Modifiers in Ruby Add modifiers after the final slash, e.g. /Regex/im, or at the beginning of the regex, e.g. /(?i)regex/. i: case insensitivity m: make the .-character also match...

makandra Curriculum

Watch Solving bizarre authorization requirements with Rails Read the Consul README Read the assignable_values README Understand how Consul...

Say you wrap your index view in a form to apply different filters like pagination or a search query. On...

...way to calculate the signature is to use an HMAC. Unfortunately, I don't believe you can calculate a proper HMAC in a regular Apache installation. Instead, we do something...

stackoverflow.com

Important You should only implement an implicit conversion method if your object already behaves like the target type. You never create a new object in an implicit conversion method...

...either return self or not be implemented at all. Obviously, this is the reason behind this recent card about Ruby implicitly converting a hash to keyword arguments. It's not...

Programatically invoke Rails generators Require the generator, instantiate it and invoke it (because generators are Thor::Groups, you need...

2013-02-20 (Tobias) ... with exactly the following rows 2012-06-20 (Henning) Better normalization (more consistent for expected/real input, gets rid of nbsps) 2012-06-01 (Tobias)

...wildcard support (partial matches) 2012-05-25 (Tobias) Better error output; "should not see" now fails if any of the rows is present; cells are now matched exactly, wildcard for...

Webpacker uses Babel and Webpack to transpile modern JavaScript down to EcmaScript 5. Depending on what browser a project needs...

Looking at the source code of the validates_numericality_of validator, it becomes clear that it converts the attribute in question to either an integer or float: if configuration[:only...

...ActiveRecord::Errors.default_error_messages[:not_a_number]) next end raw_value = raw_value.to_i else begin raw_value = Kernel.Float(raw_value.to_s) rescue ArgumentError, TypeError record.errors.add(attr_name, configuration[:message] || ActiveRecord::Errors.default...

api.rubyonrails.org

...class Image < ActiveRecord::Base; end class Video < ActiveRecord::Base; end class PageVersion < ActiveRecord::Base belongs_to :primary_medium, polymorphic: true # may be Image or Video end class Page < ActiveRecord::Base...

...belongs_to :current_version, class_name: 'PageVersion' end Now, when you load pages and include their current versions' primary media... Page.includes(:current_version => :primary_medium).to_a ... Rails will produce...

makandra is responsible for maintaining about 75 Ruby projects. These projects use a large number of different versions for Ruby...

...NonExistentClass".constantize # => NameError: uninitialized constant NonExistentClass Dynamic Programming In scenarios where your application’s behavior depends on dynamic constant resolution, safe_constantize may offer a more convenient control flow to...

...purpose of this card. Update it once a day (using whenever) Tip Consider the best place to put the new logic. Should it be an existing class or new classes...

...plain RSpec mocks ("stubs") to replace the HTTP request to the API with scripted behavior. Can you minimize the number of lines of code that now no longer run during...

thepugautomatic.com

How a macro can dynamically define a method that can be overridden with super in the same class.

ruby-lang.org

Ruby 3.0 introduced a breaking change in how it treats keyword arguments. There is an excellent blog post on the...

If you want to collapse/expand elements with dynamic content (and thus unknown height), you can not transition between height: 0...

Git commits should be very deliberate, and only contain changes that you really want to be in there. In order...

Some pseudo-elements need to be addressed with vendor prefixes. E.g. ::selection is not supported by Firefox, you need to...

The change_column method for rails migrations support casting with a custom SQL statement. This allows us to change a...

We had a card that described how to install multiple mysql versions using mysql-sandbox. Nowadays with the wide adoption...

If you want someone to be able to access your rails console, but don't want them to be able...

ruby-doc.org

...read and write access by methods like File.open and File.read. def exclusively_locked_access begin @file_locked = true File.open(F"#{file_path}.lock"), 'w+') do |f| f.flock(File::LOCK_EX...

...that block make sure to do that manually and preferably wrap it it with begin and rescue if something might go wrong: begin f = File.open(file, File::CREAT) f.flock(File...