Find conditions for scopes can be given either as an array (:conditions => ['state = ?', 'draft']) or a hash (:conditions => { 'state' => 'draft' }). The later is nicer to read, but has horrible security...

...versions of Ruby on Rails. Affected versions Version Affected? Remedy 2.3.18 yes Use chain_safely workaround 3.0.20 no 3.1.x ??? 3.2.22 yes Use Rails LTS 3.2 with hardened configuration...

...an npm package. Naming convention for pre-release versions An npm package must use Semantic Versioning's naming convention for its version. In Semantic Versioning, the version number and pre...

...release identifier (like rc1) must be separated by a dash, like this: 1.0.0-rc1 2.3.0-alpha2 3.0.0-beta3 Publishing to a pre-release tag npm packages have multiple "current" releases...

Since May 2011 we are cutting new gems using Bundler, which is less painful than cutting gems using Jeweler. You know a gem was cut using Bundler if you see...

This is how to update a gem that was cut using Bundler: Say git pull or check out a repository from Github like git clone git@github.com:makandra/geordi.git

medium.com

...end up with web page bloat. But loading a webpage is much more than shipping bytes down the wire. Once the browser has downloaded our page’s scripts it then...

...dive into this phase for JavaScript, why it might be slowing down your app’s start-up & how you can fix it. The article author also tested 6000+ production sites...

In large forms (30+ controls) new Capybara version become [extremely slow] when filling out fields. It takes several seconds per input. The reason for this is that Capybara generates a...

...huge slow XPath expression to find the field. The attached code patches fill_in with a much faster implementation. It's a dirty fix and probably does a lot less...

Ruby's String#split returns an array of substrings from the given string. Usually, this is missing the split characters: >> 'user@example.com'.split('@') => ["user", "example.com"] If you want to join those...

...parts later on, you might know the split character and can just use it to join explicitly. But if you split by a regular expression (for a set of split...

makandra dev

...methods and properties) video = document.querySelector('video') video.play() video.pause() video.load() // Reset to the beginning and select the best available source video.currentSrc // The selected source video.currentTime // The current playback time (in seconds...

...video.ended // Whether the video has finished video.muted video.paused video.readyState // See comments video.volume Comments controls makes the browser show its own video controls The image given in poster will be shown...

solnic.eu

...duplication from the code is a seemingly easy task. In many cases it is pretty straight-forward – you look at similar bits of code and you move them to a...

...in other places. Right? No, not really. It is true that code that looks similar might be an indicator that there’s a duplication but it’s not the definitive...

makandra dev
ishadeed.com

Table Of Contents Flexbox wrapping Spacing Long content Prevent an image from being stretched or compressed Lock scroll chaining CSS variable fallback Using fixed width or height...

...The fixed height The fixed width Forgetting background-repeat Vertical media queries Using justify-content: space-between Text over images Be careful with fixed values in a CSS grid

Sometimes you want to have a time in a given timezone independent from you Rails timezone settings / system timezone. I usually have this use case in tests. Example

...results e.g. 2020-08-09 00:00:00 +0200 depending on the Rails timezone settings / system timezone. But in this example we always want to have the given time in...

lesscss.org

...run by your web browser. As any JavaScript, you include a link to the script in your HTML, and…that’s that. LESS is now going to process LESS code...

ZSH is an alternative command line shell that includes some features like spelling correction, cd automation, better theme, and plugin support. You can replace Bash with ZSH like following:

...apt-get install zsh Setting ZSH as default login shell sudo usermod -s /usr/bin/zsh $(whoami) Opening a new terminal window will show you a dialog where you can configure your...

icelab.com.au

...formatting. Headers, paragraphs, lists, it’s all good. What about the formatting of text in single-line text fields? If our form entry is a single line, that’s usually...

justinfrench.com

...behavior of deprecated code in your Ruby project, the warning messages littered throughout your spec output is incredibly noisy. You could silence all warnings with ::ActiveSupport::Deprecation.silenced = true, but you...

...dependencies. It’s tempting to remove the tests altogether (the code will be burned soon too, right?), but I figured out something a little nicer a little while back in...

In rare cases you might need something like form_for (for using form builder methods on the resulting block element) but without the surrounding form. One such case would be...

...updating some of a form's fields via XHR. You can simply use Rails' fields_for to do things like this in your views (HAML here): - fields_for @user do...

makandra dev
feedjira.com

...was missing some features on Ruby's RSS::Parser that I found in Feedjira: Speed Does not break on slightly malformed RSS feeds (like a missing length attribute on an...

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

makandra dev
chrome.google.com

When you're facing a somewhat complex Google Analytics setup and want to find out what's happening, you can use this Chrome extension. It's much simpler than other...

...like "Google Tag Assistant") and does just one job and does it well. To see what's happening, you need to open your developer console...

pivotaltracker.com

The team is responsible for building great software—that’s it. It’s the only thing the team is responsible for and it’s the only thing that they actually...

...control. In other words, the development team is committed to quality software...

timeless.judofyr.net

...unknown, technique in Ruby. For certain types of problems (e.g. when you have a set of rules) this gives you such an elegant way of describing the solution. There’s...

...no meta programming or monkey patching involved, it’s short and sweet and best of all: it’s very intuitive...

jamesgolick.com

Trample is a more flexible load simulator. Instead of a static list of urls, trample's configuration language is ruby. Using ruby's blocks (lambda functions), it's possible to...

blogs.concedere.net

The goal of modelling is to produce something substantially simpler than the world. This is achieved not through endlessly inventing new types and relationships -- in fact, it's just the...

...s by eliminating entities and restricting types that we get a model that's simpler than the world and thus useful...

change_association :parent, class_name: 'Parent::AsForm', inverse_of: :children end When saving a Parent::AsForm record with nested Child::AsForm records, the children will not be saved...

...case where you override the association with has_many :children,...

...and belongs_to :parent, .... Solution This can be fixed with appending autosave: true to the Parent model: class Parent < ApplicationRecord...

Rails ships with two separate build pipelines: Sprockets ("asset pipeline") and Webpacker. Webpacker has many more moving parts, but allows us to use ES6 modules and npm packages (through Yarn...

...does for JavaScript roughly what Bundler does for Ruby. Read the first couple of sections of its official documentation. You should learn how to: Install and update packages Remove packages...