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

regular-expressions.info

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

stackoverflow.com

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

or if there are a lot of open session with status=Closing, which return Could not kill session: No such file or directory when you try to kill them...

apidock.com

...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": {

adobe.com

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

...carefully checked. In particular you will need to clean up a lot of unnecessary return statements...

...have this use case in tests. Example Time.parse('2020-08-09 00:00') will return different results e.g. 2020-08-09 00:00:00 +0200 depending on the Rails timezone...

...want to have the given time in UTC because that's what the API returns. it 'returns a valid API response', vcr: true do expect(client.get('/users/1')).to have_attributes...

makandra dev

...module_function def redis_url "redis://localhost:#{port}/#{db_number}" end def db_number # Returns a number between 2 and n. # Redis db#1 is used for development.

# of all files in app/. Files cannot change in tests, so we immediately # return if we have compiled before. if test? if @compiled_before return true else @compiled_before...

...its cache store, this is how you can list existing keys: Check: Rails.cache should return an ActiveSupport::Cache::RedisCacheStore. Rails.cache.redis.with(&:keys) lists existing keys. Cached views start with "views/".

...timer is a timeout that, when triggered, schedules itself again and again. Because $timeout returns a promise for the timer's execution, and because Coffeescript uses the last expression in...

...a block as implicit return value, this pattern is a great way to create an infinitely growing object graph. More details here. This code leaks more and more memory over...

...in Coffeescript...: @app.filter 'htmlSafe', ['$sce', ($sce) -> $sce.trustAsHtml ] # ...or JS: app.filter('htmlSafe', [ '$sce', function($sce) { return $sce.trustAsHtml; } ]); # Usage: This is a replacement for the ng-bind-html-unsafe directive which has...

...might think of XPath's contain() function: page.find(:xpath, ".//*[contains(text(), 'hello')") Unfortunately that returns a lot more elements than you expect:

hello ] What you need to do instead is...

gist.github.com

...document.body.append(overlay);function getElement(event){overlay.style.pointerEvents='none';var element=document.elementFromPoint(event.clientX,event.clientY);overlay.style.pointerEvents='auto';return element};document.addEventListener('mousemove',function(event){var element=getElement(event);if(!element)return;var position=element.getBoundingClientRect...

...document.body.append(overlay); function getElement(event) { overlay.style.pointerEvents = 'none'; var element = document.elementFromPoint(event.clientX, event.clientY); overlay.style.pointerEvents = 'auto'; return element; } document.addEventListener('mousemove', function(event) { var element = getElement(event); if (!element) return; var position = element.getBoundingClientRect...

...by disabling an unused compression webpackConfig.plugins = webpackConfig.plugins.filter(plugin => { const isBrotliCompression = plugin.constructor.name === 'CompressionPlugin' && plugin.options.algorithm === 'brotliCompress' return !isBrotliCompression }) Older Webpacker versions might need this instead: // Save compile time by disabling an unused...