Tutorial by Examples: sin

You can declare properties in interfaces. Since an interface cannot have state you can only declare a property as abstract or by providing default implementation for the accessors. interface MyInterface { val property: Int // abstract val propertyWithImplementation: String g...
The data.table package provides a convenient way to group by runs in data. Consider the following example data: library(data.table) (DT <- data.table(x = c(1, 1, 2, 2, 2, 1), y = 1:6)) # x y # 1: 1 1 # 2: 1 2 # 3: 2 3 # 4: 2 4 # 5: 2 5 # 6: 1 6 The variable x has three runs: a run ...
1) scikit learn scikit-learn is a Python module for machine learning built on top of SciPy and distributed under the 3-Clause BSD license. It features various classification, regression and clustering algorithms including support vector machines, random forests, gradient boosting, k-means and DBSCA...
<PROJECT_ROOT>\app\build.gradle is specific for app module. <PROJECT_ROOT>\build.gradle is a "Top-level build file" where you can add configuration options common to all sub-projects/modules. If you use another module in your project, as a local library you would have another...
First install the .NET Core SDK by going through the installation instructions for the platform of your choice: Windows OSX Linux Docker After the installation has completed, open a command prompt, or terminal window. Create a new directory with mkdir hello_world and change into the ne...
The where statement may be used within a switch case match to add additional criteria required for a positive match. The following example checks not only for the range, but also if the number is odd or even: switch (temperature) { case 0...49 where temperature % 2 == 0: print(&quot...
You can use an instance of an object to form your parameters public class SearchParameters { public string SearchString { get; set; } public int Page { get; set; } } var template= new SearchParameters { SearchString = "Dapper", Page = 1 }; var p = new DynamicParameters...
The functions for parsing a string into POSIXct and POSIXlt take similar parameters and return a similar-looking result, but there are differences in how that date-time is stored; see "Remarks." as.POSIXct("11:38", # time string format = "...
The quickCheck function tests a property on 100 random inputs. ghci> quickCheck prop_reverseDoesNotChangeLength +++ OK, passed 100 tests. If a property fails for some input, quickCheck prints out a counterexample. prop_reverseIsAlwaysEmpty xs = reverse xs == [] -- plainly not true for all ...
A single row of data can be inserted in two ways: INSERT INTO USERS(Id, FirstName, LastName) VALUES (1, 'Mike', 'Jones'); Or INSERT INTO USERS VALUES (1, 'Mike', 'Jones'); Note that the second insert statement only allows the values in exactly the same order as the table columns whereas in...
quickCheckAll is a Template Haskell helper which finds all the definitions in the current file whose name begins with prop_ and tests them. {-# LANGUAGE TemplateHaskell #-} import Test.QuickCheck (quickCheckAll) import Data.List (sort) idempotent :: Eq a => (a -> a) -> a -> Bool ...
What is a node.js module (link to article): A module encapsulates related code into a single unit of code. When creating a module, this can be interpreted as moving all related functions into a file. Now lets see an example. Imagine all files are in same directory: File: printer.js "use...
Assuming you created the serial port object s as in this example, then to close it fclose(s) However, sometimes you can accidentally lose the port (e.g. clear, overwrite, change scope, etc...), and fclose(s) will no longer work. The solution is easy fclose(instrfindall) More info at instrfin...
The for clause of a list comprehension can specify more than one variable: [x + y for x, y in [(1, 2), (3, 4), (5, 6)]] # Out: [3, 7, 11] [x + y for x, y in zip([1, 3, 5], [2, 4, 6])] # Out: [3, 7, 11] This is just like regular for loops: for x, y in [(1,2), (3,4), (5,6)]: print(x+y) ...
Pojo Model public class Model { private String firstName; private String lastName; private int age; /* Getters and setters not shown for brevity */ } Example: String to Object Model outputObject = objectMapper.readValue( "{\"firstName\":\"J...
Parentheses are used to enclose the arguments of function calls. Using them for procedure calls can cause unexpected problems. Because they can introduce bugs, both at run-time by passing a possibly unintended value to the procedure, and at compile-time by simply being invalid syntax. Run-time Re...
The Objective-C runtime allows you to change the implementation of a method at runtime. This is called method swizzling and is often used to exchange the implementations of two methods. For example, if the methods foo and bar are exchanged, sending the message foo will now execute the implementation...
You can use the <img> or <object> elements to embed external SVG elements. Setting the height and width is optional but is highly recommended. Using the image element <img src="attention.svg" width="50" height="50"> Using <img> does not allo...
You can add external SVG files using the background-image property, just as you would do with any other image. HTML: <div class="attention"></div> CSS: .attention { background-image: url(attention.svg); background-size: 100% 100%; width: 50px; height: ...
You can use the Enumerable class alongside Linq queries to convert for loops into Linq one liners. Select Example Opposed to doing this: var asciiCharacters = new List<char>(); for (var x = 0; x < 256; x++) { asciiCharacters.Add((char)x); } You can do this: var asciiCharacter...

Page 18 of 161