...service redis-server restart Confirm your configuration has been updated. The following command should return "OK". redis-cli select `nproc --all...
...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...
# 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...
...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...
Some browsers define window.event, which will return a copy of the "current" event. However, this is not defined by the W3C. Most importantly, Firefox does not support it, neither do...
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...
...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.
...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:
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...
...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...
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...
...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...
...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...
...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) } } Usage example function onScroll() { ... } window.addEventListener...
...match a certain criteria or not, Enumerable#partition can come in handy. # Enumerable#partition returns two arrays, # the first containing the elements of enum # for which the block evaluates to...
JavaScript Create an object with no properties with Object.create(null) => {} The comma operator returns its last expression
...simply mock time using Timecop.travel or its respective Spreewald steps and the browser will return the same time in new Date(). If you would like to stop the time from...
Ändere die Konfiguration in der ConfigMap (valide Konfiguration). Du kannst beispielsweise mit return einen custom HTTP Statuscode zurückgeben. Wird die Konfiguration jetzt erfolgreich angewendet? Verwende kubectl rollout restart...
...Erstelle eine neue ConfigMap, die den gleichen Inhalt hat wie deine bisherige. Ändere den returncode nochmals auf einen neuen Wert. Editiere das Deployment und lass es die neue ConfigMap verwenden...
...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...
...developer who just wrote it. To check its readability, a good strategy is to return after a few months. You will have forgotten the direct context, but will still be...
...will not cause problems. However, in some cases it's possible that the data returned by query that has been backed by a corrupted index would differ from a query...
...that has been backed by a correct index. It's possible that queries will return different results or the same results with different sorting after the index has been re...
...achieve this by using a callback. before_initialize :set_newsletter private def set_newsletter return unless [nil, ''].include?(receive_newsletter) self.receive_newsletter = (user.role == 'customer') end Note: When using active_type...
...Our assumption is that the element is considered visible (i.e. Capybara::Selenium::ChromeNode#visible? returns true for such elements) but the Selenium driver wants to actually click the center of...
...and .then() do not behave the same. In particular, if a standard promise callback returns another promise, this will delay the resolution of all later promises. jQuery's then behaves...
...the response, make a second request to /bar: var promise = $.ajax('/foo').done(function() { return $.ajax('/bar'); }); Quiz: When does promise resolve? Well, if you use done, it will resolve...