Tutorial by Examples: co

Tuples can be decomposed into individual variables with the following syntax: let myTuple = (name: "Some Name", age: 26) let (first, second) = myTuple print(first) // "Some Name" print(second) // 26 This syntax can be used regardless of if the tuple has unnamed properti...
Occasionally you will find the need to encode binary data as a base64-encoded string. For this we can use the DatatypeConverter class from the javax.xml.bind package: import javax.xml.bind.DatatypeConverter; import java.util.Arrays; // arbitrary binary data specified as a byte array byte[] bi...
Here is an example of a Bosun config file used in a development environment: tsdbHost = localhost:4242 httpListen = :8070 smtpHost = localhost:25 emailFrom = [email protected] timeAndDate = 202,75,179,136 ledisDir = ../ledis_data checkFrequency = 5m notification example.notification { ...
All instances of Preferences are always thread-safe across the threads of a single Java Virtual Machine (JVM). Because Preferences can be shared across multiple JVMs, there are special methods that deal with synchronizing changes across virtual machines. If you have an application which is supposed...
Using Item Sales Table from Example Database, let us calculate and show the total Quantity we sold of each Product. This can be easily done with a group by, but lets assume we to 'rotate' our result table in a way that for each Product Id we have a column. SELECT [100], [145] FROM (SELECT ItemI...
Constructor injection is the safest way of injecting dependencies that a whole class depends upon. Such dependencies are often referred to as invariants, since an instance of the class cannot be created without supplying them. By requiring the dependency to be injected at construction, it is guara...
Whilst extracting dependencies out of your code so that they can be injected makes your code easier to test, it pushes the problem further up the hierarchy and can also result in objects that are difficult to construct. Various dependency injection frameworks / Inversion of Control Containers have ...
If you want to squash the previous x commits into a single one, you can use the following commands: git reset --soft HEAD~x git commit Replacing x with the number of previous commits you want to be included in the squashed commit. Mind that this will create a new commit, essentially forgetting...
Commits can be squashed during a git rebase. It is recommended that you understand rebasing before attempting to squash commits in this fashion. Determine which commit you would like to rebase from, and note its commit hash. Run git rebase -i [commit hash]. Alternatively, you can type HE...
A controller is a basic structure used in Angular to preserve scope and handle certain actions within a page. Each controller is coupled with an HTML view. Below is a basic boilerplate for an Angular app: <!DOCTYPE html> <html lang="en" ng-app='MyFirstApp'> <head...
Dim input as String = Console.ReadLine() Console.ReadLine() will read the console input from the user, up until the next newline is detected (usually upon pressing the Enter or Return key). Code execution is paused in the current thread until a newline is provided. Afterwards, the next line of co...
Dim x As Int32 = 128 Console.WriteLine(x) ' Variable ' Console.WriteLine(3) ' Integer ' Console.WriteLine(3.14159) ' Floating-point number ' Console.WriteLine("Hello, world") ' String ' Console.WriteLine(myObject) ' Outputs the value from calling myObject.ToString() The Console.Wri...
Dim x As Int32 = 128 Console.Write(x) ' Variable ' Console.Write(3) ' Integer ' Console.Write(3.14159) ' Floating-point number ' Console.Write("Hello, world") ' String ' The Console.Write() method is identical to the Console.WriteLine() method except that it prints the given argumen...
Libraries other than jQuery may also use $ as an alias. This can cause interference between those libraries and jQuery. To release $ for use with other libraries: jQuery.noConflict(); After calling this function, $ is no longer an alias for jQuery. However, you can still use the variable jQuery...
If a lambda's capture list is empty, then the lambda has an implicit conversion to a function pointer that takes the same arguments and returns the same return type: auto sorter = [](int lhs, int rhs) -> bool {return lhs < rhs;}; using func_ptr = bool(*)(int, int); func_ptr sorter_func = ...
If you need to create a JSONObject and put data in it, consider the following example: // Create a new javax.json.JSONObject instance. JSONObject first = new JSONObject(); first.put("foo", "bar"); first.put("temperature", 21.5); first.put("year", 2016);...
If you need to get data from a JSONObject, consider the following example: String json = "{\"foo\":\"bar\",\"temperature\":21.5,\"year\":2016,\"message\":{\"Hello\":\"world\"},\"months\":[\"January\",\&qu...
Overview SelectorDescriptiondiv spanDescendant selector (all <span>s that are descendants of a <div>)div > spanChild selector (all <span>s that are a direct child of a <div>)a ~ spanGeneral Sibling selector (all <span>s that are siblings after an <a>)a + spanA...
import shutil source='//192.168.1.2/Daily Reports' destination='D:\\Reports\\Today' shutil.copytree(source, destination) The destination directory must not exist already.
The json_decode() function takes a JSON-encoded string as its first parameter and parses it into a PHP variable. Normally, json_decode() will return an object of \stdClass if the top level item in the JSON object is a dictionary or an indexed array if the JSON object is an array. It will also retur...

Page 12 of 248