cache_id && @revalidated_cache_id != cache_id end end end end If you called check_blacklist!(file) and check_content_type_blacklist!(file) in this trait, these lines should...

...active or not. This is done by settings the if:...

...kwarg within the version call. For example, if you migrated legacy videos from the old server, you still want to...

...its generators with Rails::Generators.invoke ARGV.shift, ARGV. From inside a Rails generator, you may call the inherited Thor method invoke(args=[], options={}, config={}). There also is a generate method which...

...will run the generator in a subprocess. Call it with generate 'generator_name', 'command line args'. Expected (hard-coded) directory structure of a generator #{generator namespace, e.g. rails}/ #{generator name...

makandra dev

...When a domain name is given, the non-interactive mode is used. Call nslookup without a url to start interactive mode. With interactive mode you just have to type in...

...the first line is your DNS resolver. To use a specific one, you can call nslookup like this: >nslookup heise.de 8.8.8.8 Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer:

github.com

...expect { rand(100) }.to produce_different_results, you have to use this syntax and call supports_block_expectations: RSpec::Matchers.define :produce_different_results do |sample_size: 10| supports_block_expectations...

...in JavaScript (as opposed to the code we usually write in Ruby)? What are "callbacks" in JavaScript? Can you find examples for libraries that use callbacks to deal with asynchronicity...

...for libraries that use promises to deal with asynchronicity? How can you parallelize multiple calls of an async function? Exercises Judging asynchronous code Look at the following code: async function...

makandra dev

When you call a method on an object, Ruby looks for the implementation of that method. It looks in the following places and uses the first implementation it finds:

include IncludedModule prepend PrependedModule def action puts "Klass" super end end ... and we call a method like this: instance = Klass.new instance.extend(SingletonModule) instance.action Then we get an output as...

api.rubyonrails.org

...time, use travel: travel 1.day All those methods may also receive a block to call and restore time afterwards. If you don't provide a block, you must call travel...

relishapp.com

When you are using lambdas in RSpec to assert certain changes of a call, you know this syntax: expect { playlist.destroy }.to change { Playlist.count }.by(-1) While you can define multiple...

...playlist.destroy } .to change { Playlist.count }.by(-1) .and not_change { Video.count } The above example will call playlist.destroy only once, but test both assertions. Note When you chain multiple Capybara matchers using...

makandra dev
developer.mozilla.org

...to abort async code is that your function takes a AbortSignal { signal } property. The caller can use this signal to send an abort request to your function. Upon receiving the...

...countDown() abortable Here is a variant of countDown() that may be canceled by the caller before the time has elapsed: function countDown(seconds, options = {}) { return new Promise((resolve, reject) => {

...nested_form.object will be nil. The :reject_if option lambda in your accepts_nested_attributes call is defined incorrectly. Raise the attributes hash given to your :reject_if lambda to see...

...for already iterates for you. You used form.fields_for |nested_form|, but continue to call form helpers (like text_field) on the containing form instead of nested_form.

If you already selected an element and want to get its parent, you can call find(:xpath, '..') on it. To get the grand-parent element, call find(:xpath, '../..'). Example

Rails 3, 4, 5, 6 config/application.rb config/environment.rb before the initialize! call (we don't usually edit this file) The current environment, e.g. environments/production.rb Gems Vendored plugins All initializers in config/initializers...

config/environment.rb after the initialize! call (we don't usually edit this file) Your own code from app Rails 2 Code in config/preinitializer.rb (if it exists) environment.rb, code above the...

ruby-lang.org

...is a slightly abbreviated version: What changed When the last argument of a method call is a Hash, Ruby < 3 automatically converted it to to Keyword Arguments. If you call...

...in Ruby >= 3 that accepts keyword arguments, either explicitly or via **kwargs, you cannot call it with a hash. I.e. def explicit_kwargs(x:, y:) # ... end def splat_kwargs(**kwargs...

github.com

...studies. It is based on an article written by Stephen Curtis. Table of Contents Call Stack Primitive Types Value Types and Reference Types Implicit, Explicit, Nominal, Structuring and Duck Typing...

...Operators, Type Arrays and Array Buffers DOM and Layout Trees Factories and Classes this, call, apply and bind new, Constructor, instanceof and Instances Prototype Inheritance and Prototype Chain Object.create and...

class Movie < ApplicationRecord normalizes :title, with: -> { _1.strip } end Tip Normalization lambdas are not called for nil values by default. To normalize nil values, pass an apply_to_nil: true...

...class Movie < ApplicationRecord normalizes :title, with: Normalizers::StripNormalizer end The with keyword accepts any callable object that takes the attribute’s value as its only argument. To comply with this...

...Support for combining structurally incompatible relations with and Pull request: Ignore joins on #and calls Alternative: Use SQL snippets When you call #where() with an SQL snippet string instead of...

...patch in routing-filter as it still expects an array of route data when calling super, but never actually calls the block that now needs to be called. Due to...

...this monkey patch.' end # We cannot prepend a custom extension module here because we call `super` in this method which should call the Rails # #find_routes-method and not the...

When you're nesting setTimeout(f, 0) calls, your browser will silently increase the delay to 5 milliseconds after the fourth level of nesting. This is called "timeout clamping" and...

...a similar note, all major browsers have implemented throttling rules for setInterval and setTimeout calls from tabs that are currently in the background. You can test it yourself by running...

jetbrains.com

RubyMine has a collaboration feature called "Code With Me". Using it, you can invite someone into your local editor to work together. This is nicer to the eyes and much...

...icon once a session is running. Features See other people's cursor Follow others Call others to follow you Work in full sync Work independently, but still in the same...

...What happens when an error occurs? How do we get notified? Understand that each call of a cron job will boot up your Rails application and produce 100% load on...

Sidekiq jobs should never be enqueued in an after_create or after_save callback. Can you find out why? (Hint: You can find a spoiler here)

github.com

...before continuing - the event could prevent the default behavior. Luckily there is a concept called passive event listeners which is supported by all modern browsers. Below are the key parts...

...analysis indicates that the majority of touch event handlers on the web never actually call preventDefault(), so browsers often block scrolling unnecessarily. By marking a touch or wheel listener as...

...provides a database-based model level mutex for MySQL. You use it by simply calling Lock.acquire('string to synchronize on') do # non-threadsafe code end You must make sure the...

...Only one process can enter the block using the same string, so a concurrent call to another Lock.acquire('string to synchronize on') will block, whereas Lock.acquire('some other string') will...

...it_should_act_like from our spec_candy.rb (note the /behave/act/). It allows you to call a standard shared example group with parameters. Some stupid examples follow to show how it...

it_should_act_like 'string equaling another string', :string => 'foo' end If you call it_should_act_like with a block, it will be made available as block:

...name_prefix is used. (see full_table_name_prefix in ActiveRecord::ModelSchema). The relevant call to full_table_name_prefix happens in compute_table_name. And compute_table_name is...

...called only if no table_name has been defined for a class (see reset_table_name and table_name). This is why you might be tempted to fix the odd...