Tutorial by Examples

Optimizing by using the right data structures at the right time can change the time-complexity of the code. // This variant of stableUnique contains a complexity of N log(N) // N > number of elements in v // log(N) > insert complexity of std::set std::vector<std::string> stableUnique...
Save the session variable as a variable. $session = Yii::$app->session; $sess = $session['keys']; Then create or update the array value you want $sess['first'] = 'abc'; And finally save to the session variable $session['keys'] = $sess
Returns true or false, which indicates whether the regexp is matched or not without updating $~ and other related variables. If the second parameter is present, it specifies the position in the string to begin the search. /R.../.match?("Ruby") #=> true /R.../.match?("Ruby&quot...
When storing JSON documents in SQL Server, We need to be able to efficiently filter and sort query results on properties of the JSON documents. CREATE TABLE JsonTable ( id int identity primary key, jsonInfo nvarchar(max), CONSTRAINT [Content should be formatted as JSON] CHECK...
Variadic functions are created using the ... ellipses syntax in the argument list of the function definition. function id(...) return end If you called this function as id(1, 2, 3, 4, 5) then ... (AKA the vararg list) would contain the values 1, 2, 3, 4, 5. Functions can take required arg...
As stated in the basic examples, you can have variable bound arguments and the variable argument list (...). You can use this fact to recursively pull apart a list as you would in other languages (like Haskell). Below is an implementation of foldr() that takes advantage of that. Each recursive call ...
Creating a dictionary: set mydict [dict create a 1 b 2 c 3 d 4] dict get $mydict b ; # returns 2 set key c set myval [dict get $mydict $key] puts $myval # remove a value dict unset mydict b # set a new value dict set mydict e 5 Dictionary keys can be nested. dict set mycars mustang colo...
Use a mutex to synchronise access to a variable which is accessed from multiple threads: counter = 0 counter_mutex = Mutex.new # Start three parallel threads and increment counter 3.times.map do |index| Thread.new do counter_mutex.synchronize { counter += 1 } end end.each(&:joi...
The static keyword is used on a class, method, or field to make them work independently of any instance of the class. Static fields are common to all instances of a class. They do not need an instance to access them. Static methods can be run without an instance of the class they are in. However...
Abstraction is a process of hiding the implementation details and showing only functionality to the user. An abstract class can never be instantiated. If a class is declared as abstract then the sole purpose is for the class to be extended. abstract class Car { abstract void tagLine(); } ...
Synchronized modifier is used to control the access of a particular method or a block by multiple threads. Only one thread can enter into a method or a block which is declared as synchronized. synchronized keyword works on intrinsic lock of an object, in case of a synchronized method current objects...
A variable which is declared as transient will not be serialized during object serialization. public transient int limit = 55; // will not persist public int b; // will persist
Java SE 1.2 strictfp modifier is used for floating-point calculations. This modifier makes floating point variable more consistent across multiple platforms and ensure all the floating point calculations are done according to IEEE 754 standards to avoid errors of calculation (round-off errors), ov...
This worked for me to move from Ubuntu 12.04 (Jenkins ver. 1.628) to Ubuntu 16.04 (Jenkins ver. 1.651.2). I first installed Jenkins from the repositories. Stop both Jenkins servers Copy JENKINS_HOME (e.g. /var/lib/jenkins) from the old server to the new one. From a console in the new serve...
Create a new project.json and example Program.cs: dotnet new Restore needed packages: dotnet restore Compile and run the example: dotnet run
Go to the project.json directory and publish: dotnet publish It will print the output directory of the operation, enter the directory and run the published project: dotnet <project output>.dll The default folder will be: <project root>/bin/<configuration>/<target framewo...
Simple example Assuming that the "HelloWorld.java" contains the following Java source: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } } (For an explanation of the above code, please refer to Gettin...
Standard You don't need to create the variable, but it's a good practice as you can use that variable with clearInterval to stop the currently running interval. var int = setInterval("doSomething()", 5000 ); /* 5 seconds */ var int = setInterval(doSomething, 5000 ); /* same thing, no qu...
If the program is short, you can include it in the command that runs awk: awk -F: '{print $1, $2}' /etc/passwd In this example, using command line switch -F: we advise awk to use : as input fields delimiter. Is is the same like awk 'BEGIN{FS=":"}{print $1,$2}' file Alternativelly, ...
Setting up an instance To use Realm you first need to obtain an instance of it. Each Realm instance maps to a file on disk. The most basic way to get an instance is as follows: // Create configuration RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(context).build(); // O...

Page 604 of 1336