Example This means, that we are able to overwrite these methods or call the parent version with super depending in which order and in which way they were...
...to warn the user about unsaved changes. To trigger the alert, you have to call preventDefault() on the event. Note The beforeunload event is only dispatched when the user navigation...
...alert in Chrome < 119 You might want to return any string from the event callback as this was the mechanism to trigger the alert in older browsers You cannot use...
To catch all possible exceptions from a network call, we need to rescue many error classes like this: rescue SocketError, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EHOSTUNREACH, OpenSSL::SSL...
...n\e[31mKilling Capybara session!\e[0m\n" ::Reaper.browser_died! raise end end end Call the reaper To restart the Chrome process after 50 tests, Now call StabilizeHeadlessChrome::Reaper when...
end Watch Tobias Pfeiffer's talk: Do You Need That Validation? Let Me Call You Back About It Talk with your mentor about the motivations behind the use of...
Find and talk about examples where a method should better live in a callback and vice versa Find a composition of classes and move the child classes into the...
A list of clever debugging tricks. TOC: Advanced Conditional Breakpoints monitor() class Calls Call and Debug a Function Pause Execution on URL Change Debugging Property Reads Use copy() Debugging HTML/CSS
...to express "Do this, and once you're done, do that". In contrast to callbacks, promises are easily chainable. From the readme of Q, an early implementer of the pattern...
...The callback approach is called an “inversion of control”. A function that accepts a callback instead of a return value is saying, “Don’t call me, I’ll call you...
...without a dev server When you don't have a dev server running and call any helper that accesses asset paths (e.g. javascript_pack_tag or image_tag), Rails will...
...a way to mitigate the damage. When you tell Webpacker to compile You can call bin/webpack explicitely to compile files to public/packs. When deploying with Capistrano this is done automatically...
Hint: For better testability, write a service class with the functionality and only call it in your rake task Use a namespace to rename your task to rake app...
...by adding this to your Capfile: Dir.glob('lib/capistrano/tasks/*.rake').each do |r| # `import r` calls Rake.application.add_import(r), which imports the file only # *after* this file has been processed, so...
When changing code in mailers, updating the corresponding mailer preview can be forgotten very easily. Mailer previews can be tested...
...module directives in place (require / export) Webpack replaces require and export directives with function calls to a Webpack-provided module registry. Webpack bundles everything into a single large file
Debouncing a method call delays its execution until after a specified time has passed. If it's called again before that time has passed, its execution is delayed again.
...Here is a small JavaScript function that you can use for that: function debounce(callback, delay) { let timer return function(...args) { clearTimeout(timer) timer = setTimeout(() => { callback.apply(this, args) }, delay) } }
...with a confusing stacktrace that looks like you have an error in your render call. If this happens to you, temporarily remove the annotation to see the correct error.
...performance loss, we have found it mostly correlated with high load or during video calls (i.e. GPU usage), possibly related to temperature sensors picking up rising temps. What happens is...
...the process to have it show its progress so far. From another terminal, simply call (be root or use sudo): pkill -USR1 dd This makes dd write something like this...
tl;dr: Ruby's Bundler environment is passed on to system calls, which may not be what you may want as it changes gem and binary lookup. Use Bundler.with_original...
BUNDLE_GEMFILE RUBYOPT Basically, that environment is being passed on the child calls, so when you say bundle exec and then inside make system calls.
...setting it to Timecop's time, pass a { tick: false } option to the timemachine.config() call. Note that this will not change the browser's time zone. If you mock the...
...That being said the shown process also works without creating a lock file by calling File.open(@file_path) {...
...} on the file directly instead. I will also include an example on...
Since you can't write a directory you also don't have to call #close on it...
Restart X Add a launcher icon to your gnome panel. The command to call is /home/$USER/bin/rubymine/bin/rubymine.sh. For the icon there is a nice SVG of the RubyMine logo...
...and background sections. The reason is that with background jobs (e.g. methods that are called by a cron job) some variables are not available for exception notifier, e.g. @request and...
...will crash itself and not send a mail! With foreground jobs, exception notifier gets called automatically when an error raises. For background jobs, exceptions need to be catched and delivered...
...to disable Rails internal (per-request) cache. For this, wrap your code with a call to ActiveRecord::Base.uncached. For example, as an around_filter: def disable_cache ActiveRecord::Base.uncached do...
...function that rejects: async function failingFunction() { throw new Error("Something went wrong") } When you call that function in a test, your test will fail: it('has a test', function() { failingFunction...
...have access to the rejecting promise. This can happen if the failing function is called by another function, but its rejecting promise is never returned: function wrappingFunction() { // Note we're...
...lead to this strange error (without stacktrace): irb > recipient = Recipient.find(123) Traceback (most recent call last): TypeError (nil can't be coerced into Integer) irb > recipient #<Recipient ...