...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...
...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...
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...
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
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) } }
...Consider these methods: def stuff puts 'yielding...' yield puts 'yielded.' true end We can call our stuff method with a block to yield. It works like this: >> stuff { puts 'hi...
...is Rails' capture: def capture(*args, &block) # Return captured buffer in erb. if block_called_from_erb?(block) with_output_buffer { block.call(*args) } else # Return block result otherwise, but protect...
If you have an html_safe string, you won't be able to call gsub with a block and match reference variables like $1. They will be nil inside the...
...global match object $~. While the block itself will be passed on by the super call, its global match bindings are no longer valid, as they are reset when entering a...
...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
...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...
Step into the current line step (s) Step out finish (f) Print caller stack backtrace (bt) Go one level up in the caller stack without moving the debugger...
Go one level down in the caller stack without moving the debugger down Add a new breakpoint from an existing debugger session break : \ For example: break app/models/user.rb...
...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...
...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...
...seems the deploy.rb and deploy/*.rb files are only meant for configuration, i.e. many calls to set : , . Custom tasks should live in lib/capistrano/tasks/*.rake. The deploy:restart task is not...
...directory instead of the directory you might have specified with within(...) do. I would call that a bug, but the core team disagrees. Basically, execute and capture commands behave like...
...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...
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...
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.
...uniq(x) // => [1, 2] _(x).uniq() // => [1, 2] If you want to chain multiple calls, you need to start off with a _.chain, and call value() to terminate the chain...
...map(function(i) { return i + 10 }).reverse().value() // => [12, 11] LoDash In LoDash, methods called from _ (like _.uniq) will behave as in Underscore. However, using _(...) implies chaining and most (!) methods...
...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 ...
This seems to be obvious, but you can expect Rake tasks to be called in RSpec. it 'deletes all Users' do FactroyBot.create(:user) expect(Rake::Task['notify:critical_operation']).to...
Note: Try to avoid logic in rake tasks and prefer to just call classes in them. Example: desc 'Some task' task :some_task do SomeClass.new.run
...process is still alive. Here is how to do this: In your God config, call the Rake task with an environment variable PIDFILE. This variable should equal the PID file...
...to expose your JS classes globally. // filePath is a relative path like "./foo.coffee". // The call to "substring" removes the "./" prefix. let preparePath = function(filePath) { return filePath.substring(2); }; modelFiles = require.context('js/models...
end end Step 3: Deploy and execute migrate! After deployment you can call your method in a script like this: Attachment.find_each { |attachment| attachment.file.migrate! } with class Attachment