...of hashes, where the keys are the table headers from the first row table.headers Return only the first row table.rows Return all but the first row as an array of...
...is no longer possible. You might want to set event.returnValue = true, as a truthy returnValue was necessary to trigger the alert in Chrome < 119 You might want to return any...
...page? Changes you made may not be saved.' event.returnValue = leaveMessage // support for Chrome < 119 return leaveMessage // support for older browsers } } window.addEventListener('beforeunload', warnBeforeUnload...
...your command will reveal the issue; git on the other hand will use the return value of that call to decide if the state is good or bad.
...a setter (when it gets the new value as an argument): $scope.name = function(newName) { return angular.isDefined(newName) ? (_name = newName) : _name; } You need to bind this function with ng-model and...
...angular.module('getterSetterExample', []) .controller('ExampleController', ['$scope', function($scope) { var _name = 'Brian'; $scope.user = { name: function(newName) { return angular.isDefined(newName) ? (_name = newName) : _name...
...e.g. for use in the client's browser: function svgUri(text) { let svg = ` ${text} ` return 'data:image/svg+xml;charset=utf8,' + window.escape(svg) } See the attached JSFiddle for an example.
Task.where("details->'a'->>'b' = ?", "value") # same as above, but via operator chaining -> returns JSON, whereas ->> returns text. Note that the key(s) must be passed with single quotes...
...version_appendix(version) Versionomy.parse(version) end def self.major_version_change?(version_1, version_2) return false if version_1.blank? || version_2.blank? parse_major_version(version_1) != parse_major_version(version_2)
...this in your uploaders already. end def remove_empty_container_directory(dir = store_dir) return unless Dir.empty?(dir) Dir.delete(dir) remove_empty_container_directory(File.dirname(dir)) end end
Usually, Unpoly compiler destructors are returned from the compiler function. However, when using async compiler functions, you can not register destructors via return. This will not work: up.compiler('my-example...
...async (element) => { await something return function onDestroy() { // ... } }) Instead, use up.destructor: up.compiler('my-example', async (element) => { await something up.destructor(element, function onDestroy() { // ... }) }) However, note that your element might be removed from...
...on the last argument to that method, before assigning optional arguments. If to_hash returns an instance of Hash, the hash is taken as keyword arguments to that method.
...it most likely will), Ruby will raise ArgumentError. Bah. (If to_hash does not return a Hash, assignment will work as expected – but this should actually never happen.)
...is probably \s. It matches the following whitespace characters: " " (space) \n (newline) \r (carriage return) \t (tab) \f (form feed/page break) However, in some cases these may not be good...
text: ' ', } element.addEventListener('click', (event) => { navigator.share(data) event.preventDefault() }) } If you require feedback, navigator.share will return a promise that resolves or rejects, depending on whether the sharing was completed.
...def inline!(version) # It is recommended to watch for a feature flag, see below. return version unless Rails.config.feature_inline_email_images # `attachments` is provided by Rails, see the linked documentation...
attachments[version.url] end This helper expects a Carrierwave version as in input. It returns an object that represents the attachment and responds to the #url method. Mailer view:
...option --ignore-app-not-running and due to that the command will exit with return code 0. With the next request to your application passenger will start your application based...
...with 100 comments and 10 attachments. The OUTER JOINs will cause the query to return 1000 database rows, the full cross product of the blog post × all its comments × all...
...result.to_d(0) is the required precision parameter, which is applied to the BigDecimal return value. Using Rationals has some pitfalls you should be aware of: Multiplying a Rational with...
...entire layout will probably also contain that text (in a descendant) and Capybara will return it. See Find the innermost DOM element that contains a given string. Footnotes
Furthermore, you can add a "modifier" to the percent notation to control the return type of the expression: %s Symbol %i Array of Symbols %q String
Ruby's __FILE__ keyword returns the path to the current file. On popular for this are Ruby binaries: #!/usr/bin/env ruby $LOAD_PATH << File.expand_path('../../lib', __FILE__) require 'my_cli'
...hour format, @: same, but in 12-hour am/pm format \n: newline \r: carriage return \\: backslash Colors & Styles colors have to be escaped (see General), color codes should be followed by...
...30m\]>\[\033[00m\] ' => ✔ mycomputer ~/projects/platforms master > _ # Arne's epic timestamped prompt with return status indicator and status-colored (green if fresh, or red if unstaged, or yellow if staged) git...
...which's expected name is hard coded. A popular example is extension_allowlist, which returns an array of strings and let's you only upload files that have a filename...
...Project.find_each do |project| project.recalculate_statistics! end Both find_in_batches and find_each return records ordered by ID because they need to be able to iterate in batches. Modern...
...your browser window for 10 seconds. The reason is that evaluate_script will always return a result. The return value will be converted back to Ruby objects, which in case...
...path(path, expires_at = 2.hours.from_now, allow_fuzzy_expiry: true, secret: Rails.application.secrets.url_signature_secret) return unless path uri = URI.parse(path) if allow_fuzzy_expiry expires_at = expires_at.end_of_hour...