config.before_send = lambda do |event, hint| log_sentry_event(event, hint) event # Return event so it can be processed by dummy DummyTransport end end Then add this helper...
...to shuffle an array randomly and a class that uses shuffle within the constructor. returnValue & returnValues it('shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1])
...If you have several new classes created in one test you could also use returnValues for any call of the method Random.shuffle. callFake If you are testing the class in...
...good habit to always end a composed matcher in true to ensure that it returns a truthy value. E.g. by using a condition as the last expression you may otherwise...
...hash_including( id: 1, thread: {id: 1} ) ) end end The example will fail and returns a not very helpful error message: expected {:id => 1, :name => "Foo", :thread => {:id => 1, :title...
...POST session/1230859ba100e7b2e5472cfb5bdf94c3/execute 2020-01-02 00:00:03 INFO Selenium >>> http://127.0.0.1:9538/session/1230859ba100e7b2e5472cfb5bdf94c3/execute | {"script":"return arguments[0].matches(':disabled, select:disabled *')","args":[{"ELEMENT...
var key = keyValuePair[0]; var value = keyValuePair[1]; pdfInfo[key] = decodeURI(value); } } return pdfInfo; } If you want to place repeated content outside the header or footer area, I...
...to set the Sass options. Webpacker const sassLoaderConfig = environment.loaders.get('sass') const sassLoaderIndex = sassLoaderConfig.use.findIndex(config => { return config.loader === 'sass-loader' }) // Disable deprecation warnings inside dependencies sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.quietDeps = true sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.silenceDeprecations...
...performance optimizations Removing an enum value that exists on records will make their getter return nil Neat features the generated instance methods, prefix/suffix options and scopes
timer = Capybara::Helpers.timer(expire_in: seconds) loop do prev_size = size sleep 0.025 return res if prev_size == size break if timer.expired? end raise Capybara::WindowError, "Window size not...
...to write [\s\S]or (.|\s) to match any character including line feeds, carriage returns, etc. There's a TC39 proposal that's stuck in Stage 1. While there is...
...service redis-server restart Confirm your configuration has been updated. The following command should return "OK". redis-cli select `nproc --all...
...other onbeforeunload handlers: $(function(){ document.body.onbeforeunload = function() { for(editorName in CKEDITOR.instances) { if (CKEDITOR.instances[editorName].checkDirty()) { return "Unsaved changes present!" } } } } A robuster implementation example Note: Don't forget to mark the 'search...
...method for others which need to know for unsaved changes function isUnsavedChangeConfirmed() { if (isUnsavedChangePresent()) { return confirm(warningMessage + "\n\n" + confirmationMessage); } else { return true; } } // opens a confirmation dialog if unsaved changes...
This can be especially annoying when users type something and quickly press the Return key, as they'd select the option that was just rendered. There is a loadThrottle...
an underlying Net::HTTP result, e.g. Net::HTTPUnprocessableEntity The called method will then return the return statement of the block. So this will just return the response object of...
image = params.require(:gallery).require(:add_images).first uploader = Image.new.teh_image uploader.cache! image # Return the image's cache name to the client render json: uploader.cache_name end end
submitButton.removeAttr 'disabled' # Prevent unsubmittable form (dirty fix) Helper = # Clone the template row # @return: The newly created image row addImageToForm: -> row = imageTemplate.clone() Helper.increaseTemplateIndices() row.removeClass 'gallery-form--template' row.insertBefore imageTemplate...
...where you can specify a lambda to adjust its verification response. Your callback must return either true or false and OpenSSL's verification result is the first callback block argument...
In Ruby on Rails, all objects have a useful blank? method. It returns true for nil but also for empty strings or empty arrays. There is also a universal method...
...present? which returns true for all values that are not blank?. In JavaScript you need to roll your own implementation of blank? and present?. If your application uses Unpoly you...
...class Project < ActiveRecord::Base def user "foo" end belongs_to :user end Project.new.user still returns "foo". The reason for this is that what belongs_to does is actually this:
...the qualifier. Reads like "greedy without backtracking" – *+ and ++ try to match everything but immediately return if it doesn't succeed, i.e. /\d++/ matches 333 whereas /\d++3/ does not. (A...
...not raise an exception. Instead, full_name will simply be nil, and salutation('Bob') returns 'Hi '. The same would happen in an else branch: def salutation(first_name, last_name...
...a method's source location Ruby 1.9 adds a method Method#source_location that returns file and line number where that method is defined. class Example; def method() end; end...
...reflect on the class of an instance, e.g. to decide which partial to render: Returns an instance of the specified klass with the attributes of the current record. This is...
...queue sizes, last run of Sidekiq) your application should have a monitoring route which returns a json looking like this: { "sidekiq": { "totals": { "failed": 343938, "processed": 117649167 }, "recent_history": {
...fscommand function to call a Javascript function with a fixed name from Javascript. In return Javascript can sort of communicate with ActionScript by calling SetVariable(name, value) on the Flash...