...A minimum total number of forms (both blank and pre-filled) so the user sees more than just 2 blank Actor forms when she is entering Actors for the first...

...the number of total rows. By default there is no limit. You can also set defaults for built records by adding additional keys to the options hash: form.build_nested_records...

...you pin all "important" files, you can follow method definitions, wildly open files from search results and have a ton of open tabs -- without the problem of finding the stuff...

...tabs of files that are currently in the focus of your work (important models, specs, etc): Right-click a tab and select "Pin tab" Or use a shortcut (see below...

Ruby's regular expressions can be represented differently. When serializing them, you probably want to use inspect instead of to_s. For the examples below, consider the following Regexp object...

>> regexp.to_s => "(?mi-x:^f(o+)!)" inspect As the Ruby docs say: Perhaps surprisingly, #inspect actually produces the more natural version of the string than #to_s...

With ES2021 you now can use str.replaceAll(), Promise.any(), logical assignment operators, numeric separators and WeakRef on all major browsers except IE11. replaceAll JavaScript's replace(searchValue, replaceValueOrFn) by...

...default replaces only the first match of a given String or RegExp. When supplying a RegExp as the searchValue argument, you can specify the g ("global") modifier, but you have...

makandra dev

...IDENTIFIED BY 'some_password'; GRANT REPLICATION SLAVE ON *.* TO 'replicator'@'%'; Adjust MySQL configuration : Edit /etc/mysql/my.cnf: server-id = 1 log_bin = /var/log/mysql/mysql-bin.log replicate-do-db = some_project_production replicate-do-db...

...other_project_production replicate-ignore-db = mysql server-id needs to be unique among all connected master and slave servers. When replicate-do-db is provided only the chosen databases...

# the value from the form field's ngModel (which means it's not sent to the # server, and old values would not be overwritten). # # This directive makes sure that...

...form fields with an invalid value return an # empty string instead of undefined. for elementType in ['input', 'textarea', 'select'] @app.directive elementType, -> priority: 1 restrict: 'E' require: '?ngModel' link: (scope, element...

makandra dev

We have released Modularity 2. It has many incompatible changes. See below for a script to migrate your applications automatically. There is no does method anymore We now use traits...

The script will rename your files and change your code. It will also syntax-check your files after conversion (since the script is not perfect). Check the diff...

...unwrap(). Here is how. Consider the following example element. $container = $(' Hello World ') Let's say we want to discard any tags, but keep their contents. Simply find them, then dive...

Rails 5.2+ supports "verbose query logs" where it shows the source of a query in the application log. Normally, it looks like this: User Load (0.5ms) SELECT "users".* FROM...

...app/controllers/users_controller.rb:42:in `load_users' However, you may encounter ActiveRecord's LogSubscriber as the source for all/most queries which is not helpful at all: User Load (0.5ms) SELECT "users...

When using state_machine you sometimes need to know whether an object may execute a certain transition. Let's take an arbitrary object such as a blog article as an...

...example that has those states: A -> B -> C -> D Additionally, you have transitions between the states as shown above. Let's call the transition between 'A' and 'B' transition_ab...

...so I hope it will be fixed with a future release. The following test succeeds: context 'factories' do let(:test_case) { FactoryBot.create(:test_case) } it 'are valid' do expect(test...

...byebug) FactoryBot.create(:test_case) *** NameError Exception: uninitialized constant # ::TargetLimitation Did you mean? TargetsTestScenario It seems like Byebug does not work well with zeitwerk. There is already a patch in Ruby...

...On purpose? Right... In Gnome Make it an additional ESC key by going to System -> Preference -> Keyboard -> Layouts -> Options -> CapsLock key behavior and select "Make CapsLock an additional ESC".

...to using dconf. dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:escape']" Or, open Tweak advanced GNOME 3 settings and follow Keyboard & Mouse -> Additional Layout Options to chose the same option as described above...

workingdraft.de

The robots.txt file and HTML tag can be used to control the behavior of search engine crawlers. Both have different effects. robots.txt Marking a URL path as "disallowed" in robots.txt...

...crawlers to not access that path. robots.txt is not a guarantee for exclusion from search engine results. A "disallowed" URL might be known from an external link, and can still...

...links. Popular pagination libraries like will_paginate or Kaminari do this for us by simply issuing an extra query, like this: SELECT post.* FROM posts LIMIT 20 OFFSET 100;

...of the time. But rarely, you might have very complicated WHERE conditions or a subquery that takes time to run. In these cases, doing two queries is slower than it...

Note: Making a reverse proxy with nginx is much more straightforward. A reverse proxy is a "man in the middle" server that tunnels requests to another server. You can use...

...makes sure that it can fetch from HTTPS internally. You've basically built your custom SSL-stripping MITM attack server. If your proxy server should be accessible over HTTPS, use...

A print stylesheet is easy to create. Choose a font suited for paper, hide some elements, done. Unfortunately print stylesheets often break as the application is developed further, because they...

...are quickly forgotten and nobody bothers to check if their change breaks the print stylesheet. This card describes how to write a simple Cucumber feature that tests some aspects of...

...Ever wanted to give an element "the container's width minus 20px on each side"? Here you go: .foo { width: calc(100% - (20px * 2)); } When using Sass, you need to...

...interpolate Sass expressions: $margin: 20px * 2 .foo width: calc(100% - #{$margin}) Supported by all modern browsers and IE9...

This is how you regain disk space from OpenStack instances if you are using kvm and qcow. If your instance used up all configured disk space once the disk file...

...remains big. You can end up in a situation where for example the instance use only 20GB disk space but the disk file on the server has 100GB (or even...

...message like this, rubygems.org might have issues with their ipv6 connectivity: $ bundle install Fetching source index from https://rubygems.org/ Retrying fetcher due to error (2/4): Bundler::HTTPError Could not fetch...

...specs from https://rubygems.org/ due to underlying error <timed out (https://rubygems.org/specs.4.8.gz)> The (a little bit dirty) possible solution If that's actually the case, then you can try...

makandra Curriculum

What are the advantages of a gem like memoized over the @variable ||= syntax? Why can it be dangerous to memoize class methods? Why is it often fine to...

...memoize instance methods? Resources Speeding up Rails with Memoization 4 Simple Memoization Patterns in Ruby (And One Gem) Don't use the || operator to set defaults Exercise

makandra dev

...of control”. A function that accepts a callback instead of a return value is saying, “Don’t call me, I’ll call you.”. Promises un-invert the inversion, cleanly separating...

...the input arguments from control flow arguments. This simplifies the use and creation of APIs, particularly variadic, REST and spread arguments. Note that promises are not a drop-in replacement...

web.archive.org

Capistrano 2 brings the shell command which allows you to run commands on your deployment targets. There is also invoke to run a command directly from your terminal.

...allow running Capistrano tasks or shell commands, and scope to individual machines or machine roles. Unfortunately Capistrano 3 does not include these commands any more. cap shell Basics

jQuery doesn't store information about event listeners and data values with the element itself. This information is instead stored in a global, internal jQuery cache object. Every time you...

...gets deleted is when you call remove() on the element that put it there! Since cache entries also have a pointer back to the element that spawned them, it is...

github.com

When using Sidekiq in your application, you must write thread-safe code. This wiki page also lists gems that are known to be unsafe on threaded applications.

...gem that will also be used by a Sidekiq worker, make sure to confirm it's thread-safe...