...If you don't speak CoffeeScript, take this JavaScript: this.app.decorator('$httpBackend', ['$delegate', function($delegate) { return function() { var headers = arguments[4]; var contentType = (headers != null ? headers['X-Force-Content-Type'] : void...

...if (contentType != null && headers['Content-Type'] == null) { headers['Content-Type'] = contentType; } return $delegate.apply(null, arguments...

developer.mozilla.org

You can easily have a JavaScript hash/object that returns a default value for unset keys/properties -- as long as you need to support only recent browsers. The key are JavaScript proxies...

...getter method. They work like this: var hash = new Proxy({}, { get: function(object, property) { return object.hasOwnProperty(property) ? object[property] : 'hello'; } }); When you set a key, you can read its value...

...Sass function is computing a result that is neither assigned to a variable nor returned. Keep in mind that all functions in Sass return something, Sass does not mutate objects...

...get: () => value, set: (newValue) => value = newValue } delete newDescriptor.value delete newDescriptor.writable Object.defineProperty(obj, prop, newDescriptor) return spyOnProperty(obj, prop, accessType...

Consider you have a website vhost listening to www.example.com, redirecting all incoming requests that do not talk about the configured...

...var container = $.find('.container', document.body)[0]; var openTasks = $.find('.task.open', container); Note that Sizzle returns vanilla DOM nodes in a vanilla Javascript array. It does not return jQuery collections...

...child of the element we're checking var candidateFromPoint = $(elementFromPoint).closest(elementFromSelector).get(0); return elementFromSelector == candidateFromPoint; JS is_top_element = page.execute_script(js) expect(is_top_element).to eq...

...for(locator) method, which takes a prose locator like "the very important notice" and returns a CSS selector like .very-important-notice. If you are using Spreewald, this method is...

...requests for every page. The browser will first request /foo, then the server will return a redirect to /foo/ (mind the trailing slash), then the browser makes a second request...

...by configuring your static web server. What we want is: Accessing /foo should directly return the content of /foo/index.html without a redirect Accessing /foo/ should redirect to the canonical /foo...

angular-tips.com

...app.factory('name', someFunction) someFunction is called when the name service is instantiated and should return an object Service just like Factory, but: instead of a funciton, it receives a Javascript...

^ app.config(function($provide) { $provide.decorator('serviceToBeDecorated', function($delegate) { // modify $delegate by adding functions etc. return $delegate; }); }); More differences | | Factory | Service | Value | Constant | Provider | | can have dependencies | yes | yes | no | no...

should include the model and tag if the tool has a tag should return the model if the tool has no tag .search should find tools by model and...

blog.jayfields.com

...legacy code. For new code, always use capture3. %x{ } or backticks – quick and easy Returns the standard output of running the given command in a subshell. This is an alias...

...exec, but executes the given command in a subshell. Your script will go on. Returns: true if the command gives zero exit status false for non zero exit status

...attr_writer :browser_died def scenario_started self.browser_died = false end def scenario_ended return unless session.driver.is_a?(::Capybara::Selenium::Driver) self.driver_scenario_count += 1 if !browser_died? && driver_scenario...

makandra dev

...image_tag), Rails will compile your entire assets within its process before that helper returns. This will cause your helper to freeze for many seconds. Since Webpack needs to boot...

...for RSpec users: |---------------------------------------------------------| | RSpec | Mocha | |---------------------------------------------------------| | obj = double() | obj = mock() | | obj.stub(:method => 'value') | obj.stubs(:method).returns('value') | | obj.should_receive(:method).with('argument').and_return('value') | obj.expects(:method).with('argument').returns('value...

makandra dev

...below gives you just that. // Call with two desired values at two different widths. // Returns a calc() expression that will scale proportionally between those two. // Example: // Spacing should be 15px...

$width2 * $relative + $static = $spacing2 $relative: ($spacing2 - $spacing1) / ($width2 - $width1) $static: $spacing1 - ($width1 * $relative) @return calc(#{$relative * 100%} + #{$static * 1px...

...Laden von Models passieren # search_spec.rb describe Search, search: true do # enable indexing # ... it 'only returns posts for a post query' do post = create(:post) create(:event) Post.search_index.refresh # force index to...

edgeapi.rubyonrails.org

# or b.label(class: "my-#{ b.object.class.name.parameterize }", 'data-value': b.value) { b.check_box + b.text } end The return values of each call will be joined and returned. You may of course render HTML...

...the element "([^\"]+)" should( not)? have scrollbars$/ do |selector, no_scrollbars| scroll_height = page.execute_script("return $('#{selector}').get(0).scrollHeight;") offset_height = page.execute_script("return $('#{selector}').get(0).offsetHeight;") comparison = no...

RuntimeError: can't modify frozen String /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/version.rb:191:in `strip!': #stringify_keys - returns hash or session hash with keys stringified /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/1.9.1/rubygems/version.rb:191:in `initialize' /home/user/.rbenv/versions/1.9.3-p551/lib/ruby/gems/1.9.1/gems/pry-0.13.1/lib/pry/pry_class.rb:13:in `new...

...is some plain JavaScript, should you prefer that: function joinSentence(array) { if (array.length > 1) { return array.slice(0, -1).join(', ') + ', and ' + array.slice(-1); } else { return array.join...

...form = up.element.first(formSelector) element.addEventListener('click', (event) => { event.preventDefault() let linkTag = buildLinkTag(form) if (linkTag == null) return window.parent.postMessage({ mceAction: 'insertContent', content: linkTag, }); window.parent.postMessage({ mceAction: 'insertContent', content: ' ', }) window.parent.postMessage({ mceAction: 'close' }); }) function buildLinkTag(form...

...extra attribute) you might run into trouble when submitting the form by pressing the return key in a field. When nothing fancy like a tabindex is defined it seems as...

...submit element inside a form is chosen (and has its attributes submitted) when pressing return.\ So, if possible, put your "default" (aka least harmful) submit element before others.

...parentheses) instead of using it as a keyword import (without parentheses). The import() function returns a promise with the exported variables: let exports = await import('large-library') console.log("A named...

makandra dev

...video's initial playback time. Setting this value seeks to the new time. readyState returns a value in [0:4] indicating its state. Caveats On iOS, the video.preload attribute is...