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

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

makandra dev

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

makandra dev

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

github.com

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

ruby-doc.org

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

makandra dev
semaphoreci.com

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

...der DynamoDB zurückzuführen sind, wenn die Anwendung viel Traffic hat. Die Funktionslogik der API-Calls in der Applikation kann nicht geändert werden. Welche Möglichkeit gibt es das Problem zu lösen...

makandra dev

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

makandra dev

...effect. That's because Spring preloads and caches your application once and all consecutive calls to it will not see any changes in your debugged gem. Howto Disable spring with...

...environment variables that subprocesses will see. For tests with a Rails application (i.e., that call rails or rake or other binstubbed commands), this method may help you: # Use this method...

...SERVICE = _SERVICE_ afterEach -> @$httpBackend.verifyNoOutstandingExpectation() @$httpBackend.verifyNoOutstandingRequest() describe 'FUNCTION()', -> it 'does something', -> # Maybe some code here # Call function under test (triggers API request, which will be intercepted) @SERVICE.FUNCTION()

...do something before request...

...assumes you have already employed ngMock MODULE is your Angular module, e.g. backend All calls to module must occur before any calls to inject You need to disable uiRouter's...

Additionally, you have transitions between the states as shown above. Let's call the transition between 'A' and 'B' transition_ab for simplicity. \ Given an object in state...

...A'. You can call object.transition_ab but calling object.transition_bc! will obviously fail because there's no such transition for state 'A'. Now if you need to check whether you...