The Angular 1.2 way: # By default, angular returns undefined for invalid attributes which removes # the value from the form field's ngModel (which means it's not sent to the...

...not be overwritten). # # This directive makes sure that form fields with an invalid value return an # empty string instead of undefined. for elementType in ['input', 'textarea', 'select'] @app.directive elementType, ->

...folders, you might consider setting this keyboard to "Copy From Repository Root". This will return the path spec/foo_spec.rb instead of foo_spec.rb. Caveat: This will not copy the line number...

...as described in the documentation. For example load ace Editor like this: function loadAceEditor() { return import(/* webpackChunkName: "ace" */ 'ace-builds/src-noconflict/ace').then(() => { return import(/* webpackChunkName: "ace" */ 'ace-builds/webpack-resolver.js') }) }

...and sync any changes into the textarea. $element.hide() session.setValue($element.val()) session.on('change', () => { $element.val(session.getValue()) }) return () => { editor.destroy...

...of the weekday in Ruby as defined by ISO 8601, use Date#cwday, which returns values in 1..7 (mind the range difference to Date#wday). The first week of...

...the calendar week in Ruby as defined by ISO 8601, use Date#cweek, which returns values in 1..53 USA and Canada Not defined in a standard. Weeks start on...

...both its group and its group_id: user = User.find(1) user.group = Group.find(3) user.group # returns # user.group_id = 4 user.group_id # returns 4 user.save After the save, the change to group...

...id will be lost: user.group # returns # user.group_id # returns...

...need a specific wrapper for the code. Use a function when: You need to return data from the code. You don't need to specify a resource name.

...use .to_json instead of .iso8601 to use the build-in eq matcher: it 'returns the created at attribute of a user' do get '/users/1' expect(JSON.parse(response.body)['created_at...

...seems also to have problems with zeitwerk, since the create statement just didn't return. Pry (binding.pry) worked without problems for me. Note: In case you are using pry-byebug...

...to get to a pagination page that does not exist), the database will not return a record and so you will not get the count. To work around this, I...

makandra Curriculum

The class should cache its results so subsequent calls for the same URLs return the HTML size instantly, without making an additional HTTP request. Write two versions of WebsiteSizer...

makandra dev
select2.org

"more": true } } Basic ajax options $('#mySelect2').select2({ ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax

...to die for this code: function effectiveDeviceWidth() { var deviceWidth = window.orientation == 0 ? window.screen.width : window.screen.height; // iOS returns available pixels, Android returns pixels / pixel ratio // http://www.quirksmode.org/blog/archives/2012/07/more_about_devi.html if (navigator.userAgent.indexOf('Android') >= 0 && window.devicePixelRatio...

...deviceWidth = deviceWidth / window.devicePixelRatio; } return deviceWidth...

...The AJAX call is asynchronously and we don't have control over when it returns (and hence when it calls the callback function). Here is a test that does all...

We're using jasmine-ajax to mock access to the network. jasmine.Ajax.requests.mostRecent() returns the most recent AJAX request, which we can inspect for its parameters and payload. We...

...instance to fill in text. Ensure everything is loaded with patiently do page.execute_script("return isCkeditorLoaded('#{selector}');").should be_true end Example The fill in text snippet for Cucumber:

...I fill in the "([^\"]+)" WYSIWYG editor with:$/ do |selector, html| patiently do page.execute_script("return isCkeditorLoaded('#{selector}');").should be_true end html.gsub!(/\n+/, "") # otherwise: unterminated string literal (Selenium::WebDriver::Error...

docs.gitlab.com

...the same job. If you configure one job to use both keywords, the linter returns a key may not be used with rules error. GitLab 12.3 introduced rules. You can...

docs.angularjs.org

...you are using Coffeescript, it is likely to be the culprit. Since Coffeescript always returns the value of the last expression, it may return DOM nodes: # coffeescript scope.focus = -> element.focus()

...scope.focus = function() { return element.focus(); // wheee } If you e.g. use this function like this, the error will be raised:

Solution By adding an explicit return value (e.g. return false), you can...

...Element attribute" To access virtually anything, create a "Custom Javascript" variable. Define a function() { return ...; } that returns whatever you need. You can reference other GTM variables with {{ }}.

Previous versions of Consul exhibited strange behavior when querying a power that returns nil. Consul 0.4.2+ behaves as expected: power.notes # => returns nil power.notes? # => returns false power.notes! # => raises Consul::Powerless

...Note.last) # => returns false power.note!(Note.last) # => raises Consul::Powerless

...useful methods: URLSearchParams.append() - appends a query parameter URLSearchParams.delete() - deletes the specified query parameter URLSearchParams.get() - returns the value of the specified query parameter URLSearchParams.has() - checks if specified query parameter exists URLSearchParams.set...

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