Tutorial by Examples: al

To check if a required gem is installed, from within your code, you can use the following (using nokogiri as an example): begin found_gem = Gem::Specification.find_by_name('nokogiri') require 'nokogiri' .... <the rest of your code> rescue Gem::LoadError end However, this can ...
You use the condition attribute to specify the condition to use. <cfset myVar=false> <cfloop condition="myVar eq false"> <cfoutput> myVar = <b>#myVar#</b> (still in loop)<br /> </cfoutput> <cfif RandRange(1,10) eq 10> ...
Python multithreading performance can often suffer due to the Global Interpreter Lock. In short, even though you can have multiple threads in a Python program, only one bytecode instruction can execute in parallel at any one time, regardless of the number of CPUs. As such, multithreading in cases w...
If an array happens to have one or more nil elements and these need to be removed, the Array#compact or Array#compact! methods can be used, as below. array = [ 1, nil, 'hello', nil, '5', 33] array.compact # => [ 1, 'hello', '5', 33] #notice that the method returns a new copy of the array w...
We can use flatten() in order to lazily reduce the nesting of a multi-dimensional sequence. For example, lazy flattening a 2D array into a 1D array: // A 2D array of type [[Int]] let array2D = [[1, 3], [4], [6, 8, 10], [11]] // A FlattenBidirectionalCollection<[[Int]]> let lazilyFlatten...
Perform the following steps to create the library: Create a GitHub account. Create a Git repository containing your library project. Modify your library project's build.gradle file by adding the following code: apply plugin: 'com.github.dcendents.android-maven' ... // Build a j...
Validate that an attribute's value matches a regular expression using format and the with option. class User < ApplicationRecord validates :name, format: { with: /\A\w{6,10}\z/ } end You can also define a constant and set its value to a regular expression and pass it to the with: option. ...
You can check if a value is included in an array using the inclusion: helper. The :in option and its alias, :within show the set of acceptable values. class Country < ApplicationRecord validates :continent, inclusion: { in: %w(Africa Antartica Asia Australia ...
Add the [Serializable] attribute to mark an entire object for binary serialization: [Serializable] public class Vector { public int X; public int Y; public int Z; [NonSerialized] public decimal DontSerializeThis; [OptionalField] public string Name; } All...
If you use the [NonSerialized] attribute, then that member will always have its default value after deserialization (ex. 0 for an int, null for string, false for a bool, etc.), regardless of any initialization done in the object itself (constructors, declarations, etc.). To compensate, the attribut...
That would get more control over serialization, how to save and load types Implement ISerializable interface and create an empty constructor to compile [Serializable] public class Item : ISerializable { private string _name; public string Name { get { return _name; } ...
Implements a serialization surrogate selector that allows one object to perform serialization and deserialization of another As well allows to properly serialize or deserialize a class that is not itself serializable Implement ISerializationSurrogate interface public class ItemSurrogate : ISerial...
For queries, Realm provides the realmResults.asObservable() method. Observing results is only possible on looper threads (typically the UI thread). For this to work, your configuration must contain the following realmConfiguration = new RealmConfiguration.Builder(context) // ...
This example goes over how to set up CoreNLP from the latest official release. This example will take you through downloading the package, and running a simple command-line invocation of CoreNLP. Prerequisites: Java JVM 8. The command java -version should complete successfully with a line like: ...
A class or struct can also define member type aliases, which are type aliases contained within, and treated as members of, the class itself. struct IHaveATypedef { typedef int MyTypedef; }; struct IHaveATemplateTypedef { template<typename T> using MyTemplateTypedef = std::v...
Quantitative data is often read in as strings that must be converted to numeric types before processing. The types of all list items can be converted with either a List Comprehension or the map() function. # Convert a list of strings to integers. items = ["1","2","3",...
Detailed instructions on getting docusignapi set up or installed.
To improve performance one might want to add indexes to columns ALTER TABLE TABLE_NAME ADD INDEX `index_name` (`column_name`) altering to add composite (multiple column) indexes ALTER TABLE TABLE_NAME ADD INDEX `index_name` (`col1`,`col2`)
SELECT is used to retrieve rows of data from a table. You can specify which columns will be retrieved: SELECT Name, Position FROM Employees; Or just use * to get all columns: SELECT * FROM Employees;
A compound literal is an unnamed object which is created in the scope where is defined. The concept was first introduced in C99 standard. An example for compound literal is Examples from C standard, C11-§6.5.2.5/9: int *p = (int [2]){ 2, 4 }; p is initialized to the address of the first ele...

Page 108 of 269