Tutorial by Examples: au

The &AUX keyword can be used to define local variables for the function. They are not parameters; the user cannot supply them. &AUX variables are seldomly used. You can always use LET instead, or some other way of defining local variables in the function body. &AUX variables have the a...
The normal orElse method takes an Object, so you might wonder why there is an option to provide a Supplier here (the orElseGet method). Consider: String value = "something"; return Optional.ofNullable(value) .orElse(getValueThatIsHardToCalculate()); // returns "some...
First choose your auth strategy and add it to your Gemfile. You can find a list of strategies here: https://github.com/intridea/omniauth/wiki/List-of-Strategies gem 'omniauth-github', :github => 'intridea/omniauth-github' gem 'omniauth-openid', :github => 'intridea/omniauth-openid' You ca...
Reading the contents of a file within a web application can be accomplished by utilizing the HTML5 File API. First, add an input with type="file" in your HTML: <input type="file" id="upload"> Next, we're going to add a change listener on the file-input. This e...
Introduced in Java 8, default methods are a way of specifying an implementation inside an interface. This could be used to avoid the typical "Base" or "Abstract" class by providing a partial implementation of an interface, and restricting the subclasses hierarchy. Observer patte...
Sometimes you want to destructure key under a map which might not be present in the map, but you want a default value for the destructured value. You can do that this way: (def my-map {:a 3 :b 4}) (let [{a :a b :b :keys [c d] :or {a 1 c 2}} my-map] (println ...
${parameter:-word} If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted. $ unset var $ echo "${var:-XX}" # Parameter is unset -> expansion XX occurs XX $ var="" # Parameter is null ...
DefaultIfEmpty is used to return a Default Element if the Sequence contains no elements. This Element can be the Default of the Type or a user defined instance of that Type. Example: var chars = new List<string>() { "a", "b", "c", "d" }; chars.Defaul...
While there are many parameters that can be changed and variations that can be added depending on the desired functionality, this example lays out the basic framework for launching PowerPoint. Note: This code requires that the PowerPoint reference has been added to the active VBA Project. See th...
You can create a UIColor from a hexadecimal number or string, e.g. 0xff00cc, "#FFFFFF" Swift Int Value extension UIColor { convenience init(hex: Int, alpha: CGFloat = 1.0) { let r = CGFloat((hex >> 16) & 0xff) / 255 let g = CGFloat((hex >> 08) &amp...
The default event for the Page object is Load event. Similarly, every control has a default event. For example, default event for the button control is the Click event. The default event handler could be created in Visual Studio, just by double clicking the control in design view. The following tab...
Mage::log('My log entry'); Mage::log('My log message: '.$myVariable); Mage::log($myArray); Mage::log($myObject); This will log to /var/log/system.log Objects and Arrays are automatically written via a print_r() directive. Watch out when using objects since these can get substantial in size. ...
In this example we show how to generate a simple sine wave, and output it on the user's speakers/headphones. let audioContext = new (window.AudioContext || window.webkitAudioContext)(); let sourceNode = audioContext.createOscillator(); sourceNode.type = 'sine'; sourceNode.frequency.value = 261...
Effects can be applied to audio by chaining nodes between the source and the destination node. In this example we use a gain node to mute the source, and only let sound through at specific times. This allows us to create morse code. function morse(gainNode, pattern) { let silenceTimeout = 300; ...
Be careful with semicolons. Following example if (x > a); a = x; actually means: if (x > a) {} a = x; which means x will be assigned to a in any case, which might not be what you wanted originally. Sometimes, missing a semicolon will also cause an unnoticeable problem: if (i &lt...
Initialize a UICollectionView with a CGRect frame: Swift: let collection = UICollectionView(frame: CGRect(x: 0, y: 0, width: 200, height: 21)) Objective C: UICollectionView *collection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 200, 21)]; You can also create a UICollectionVi...
The following example adds a column admin to the users table, and gives that column the default value false. class AddDetailsToUsers < ActiveRecord::Migration[5.0] def change add_column :users, :admin, :boolean, default: false end end Migrations with defaults might take a long tim...
;; package.el is available since emacs 24 (require 'package) ;; Add melpa package source when using package list (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t) ;; Load emacs packages and activate them ;; This must come before configurations o...
In order to record audio from a user's microphone, we must first gain permission from the user to access the device: navigator.mediaDevices.getUserMedia({ audio: true }) .then(successCallback) .catch(failureCallback); On success, our successCallback will be called with a MediaStream ob...
The keyword auto provides the auto-deduction of type of a variable. It is especially convenient when dealing with long type names: std::map< std::string, std::shared_ptr< Widget > > table; // C++98 std::map< std::string, std::shared_ptr< Widget > >::iterator i = table.fin...

Page 8 of 37