Tutorial by Examples: sin

We define two sets a and b >>> a = {1, 2, 2, 3, 4} >>> b = {3, 3, 4, 4, 5} NOTE: {1} creates a set of one element, but {} creates an empty dict. The correct way to create an empty set is set(). Intersection a.intersection(b) returns a new set with elements present in bot...
To list available local versions of node through NVM: nvm ls For example, if nvm ls returns: $ nvm ls v4.3.0 v5.5.0 You can switch to v5.5.0 with: nvm use v5.5.0
To connect using java.sql.DriverManager you need a JDBC url to connect to your database. JDBC urls are database specific, but they are all of the form jdbc:<subprotocol>:<subname> Where <subprotocol> identifies the driver or database (for example postgresql, mysql, firebirdsql,...
The intrinsic pack function packs an array into a vector, selecting elements based on a given mask. The function has two forms PACK(array, mask) PACK(array, mask, vector) (that is, the vector argument is optional). In both cases array is an array, and mask of logical type and conformable with...
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Specify a controller using the fx:controller attribute and get the controller instance created during the loading process from the FXMLLoader instance used to load the fxml. Add methods for passing the data to the contr...
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Set the controller using the FXMLLoader instance used later to load the fxml. Make sure the controller contains the relevant data before loading the fxml. Note: in this case the fxml file must not contain the fx:contro...
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Specify a controller factory that is responsible for creating the controllers. Pass the data to the controller instance created by the factory. FXML <?xml version="1.0" encoding="UTF-8"?> &...
LinqPad is a great tool that allows you to learn and test features of .Net languages (C#, F# and VB.Net.) Install LinqPad Create a new Query (Ctrl + N) Under language, select "C# statements" Type the following code and hit run (F5) string hw = "Hello World&quo...
Aliasing types cuts down on boilerplate and enhances readability, but it is no more type-safe than the aliased type itself is. Consider the following: type alias Email = String type alias Name = String someEmail = "[email protected]" someName = "Benedict" sendEmail ...
Metaclass syntax Python 2.x2.7 class MyClass(object): __metaclass__ = SomeMetaclass Python 3.x3.0 class MyClass(metaclass=SomeMetaclass): pass Python 2 and 3 compatibility with six import six class MyClass(six.with_metaclass(SomeMetaclass)): pass
<!--- Define collection ---> <cfset attributes = { "name": "Sales", "type": "text", "value": "Connection" }> <!--- cfloop tag with attribute collection can be used to loop through the elements of a struc...
<cfscript> /*define collection*/ attributes = { "name": "Sales", "type": "text", "value": "Connection" }; for(attribute in attributes){ /* attribute variable will contain the key name of each key value ...
let rec factorial n = match n with | 0 | 1 -> 1 | n -> n * (factorial (n - 1)) This function matches on both the values 0 and 1 and maps them to the base case of our recursive definition. Then all other numbers map to the recursive call of this function.
The following assumes you will use kdiff3 for file diffing and although not essential it is a good idea. C:\> choco install kdiff3 Git can be installed first so you can state any parameters you wish. Here all the Unix tools are also installed and 'NoAutoCrlf' means checkout as is, commit as i...
Unlike the other helpers, this one uses static class helpers to serialize and deserialize, hence it is a little bit easier than the others to use. using Newtonsoft.Json; var rawJSON = "{\"Name\":\"Fibonacci Sequence\",\"Numbers\":[0, 1, 1, 2, 3, 5, 8, 13]}...
Pass a dict object to field_name__contains as a keyword argument. Catalog.objects.filter(titles__contains={ 'Pro Git': 'Scott Chacon and Ben Straub'}) Equivalent to the SQL operator `@>`.
You often find yourself in a situation where you need to find a variables corresponding value, and collections got you covered. In the example below we got three different locales in an array with a corresponding calling code assigned. We want to be able to provide a locale and in return get the as...
You can test if a string matches several regular expressions using a switch statement. Example case "Ruby is #1!" when /\APython/ puts "Boooo." when /\ARuby/ puts "You are right." else puts "Sorry, I didn't understand that." end This w...
ClientContext clientContext = new ClientContext(siteUrl); Web oWebsite = clientContext.Web; ListCollection collList = oWebsite.Lists; clientContext.Load(collList); clientContext.ExecuteQuery(); foreach (List oList in collList) { Console.WriteLine("Title: {0} Created: {1}",...
ClientContext clientContext = new ClientContext(siteUrl); Web oWebsite = clientContext.Web; ListCollection collList = oWebsite.Lists; IEnumerable<List> resultCollection = clientContext.LoadQuery( collList.Include( list=>list.Title, list=>list.Id)); clientCo...

Page 39 of 161