Tutorial by Examples: sin

In Groovy, the inject() method is one of the cumulative methods that allows us to add (or inject) new functionality into any object that implements the inject() method. In the case of a Collection, we can apply a closure to a collection of objects uniformly and then collate the results into a single...
Since there is no STRING_SPLIT function we need to use XML hack to split the string into rows: Example: SELECT split.a.value('.', 'VARCHAR(100)') AS Value FROM (SELECT Cast ('<M>' + Replace('A|B|C', '|', '</M><M>')+ '</M>' AS XML) AS Data) AS A CROSS apply data...
The :on option lets you specify when the validation should happen. The default behavior for all the built-in validation helpers is to be run on save (both when you're creating a new record and when you're updating it). class Person < ApplicationRecord # it will be possible to update email wi...
UIView *view = [[UIView alloc] init]; [self.view addSubview:view]; //Use the function if you want to use height as constraint [self addView:view onParentView:self.view withHeight:200.f]; //Use this function if you want to add view with respect to parent and should resize with it [self a...
To help you find and count characters in a string, CharMatcher provides the following methods: int indexIn(CharSequence sequence) Returns the index of the first character that matches the CharMatcher instance. Returns -­1 if no character matches. int indexIn(CharSequence sequence, int sta...
textBox.KeyPress += (sender, e) => e.Handled = !char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar); This will only permit the use of digits and control characters in the TextBox, other combinations are possible using the same approach of setting the Handle property to true to block ...
Download the Apache Felix Framework Distribution and extract it into a directory: $ tar xf org.apache.felix.main.distribution-5.4.0.tar.gz $ cd felix-framework-5.4.0 And then start the framework with the following command: $ java -jar bin/felix.jar ____________________________ Welcome to...
In most cases, it is illegal to access an object of one type as though it were a different type (disregarding cv-qualifiers). Example: float x = 42; int y = reinterpret_cast<int&>(x); The result is undefined behavior. There are some exceptions to this strict aliasing rule: An obj...
The ProcessBuilder class makes it easy to send a command through the command line. All it requires is a List of Strings that make up the commands to be entered. You simply call the start() method on your ProcessBuilder instance to execute the command. If you have a program called Add.exe which take...
This proxy simply appends the string " went through proxy" to every string property set on the target object. let object = {}; let handler = { set(target, prop, value){ // Note that ES6 object syntax is used if('string' === typeof value){ target[prop] = valu...
Laravel's events allows to implement the Observer pattern. This can be used to send a welcome email to a user whenever they register on your application. New events and listeners can be generated using the artisan command line utility after registering the event and their particular listener in App...
Though the transaction class method is called on some ActiveRecord class, the objects within the transaction block need not all be instances of that class. This is because transactions are per-database connection, not per-model. In this example a balance record is transactionally saved even though ...
Using NuGet Install-Package Cirrious.FluentLayout An expanded example based on the starter example at the GitHub Page, a simple first name, last name labels and fields all stacked one on top of the other: public override void ViewDidLoad() { //create our labels and fields var firstNa...
Built-in functionals: lapply(), sapply(), and mapply() R comes with built-in functionals, of which perhaps the most well-known are the apply family of functions. Here is a description of some of the most common apply functions: lapply() = takes a list as an argument and applies the specified ...
User-defined functionals Users can create their own functionals to varying degrees of complexity. The following examples are from Functionals by Hadley Wickham: randomise <- function(f) f(runif(1e3)) lapply2 <- function(x, f, ...) { out <- vector("list", length(x...
Using SVG stroke makes it easier to create a Vector drawable with unified stroke length, as per Material Design guidelines: Consistent stroke weights are key to unifying the overall system icon family. Maintain a 2dp width for all stroke instances, including curves, angles, and both interior and ...
To print a test field (TestField) from a test feature class (TestFC) in a test file geodatabase (Test.gdb) located in a temporary folder (C:\Temp): with arcpy.da.SearchCursor(r"C:\Temp\Test.gdb\TestFC",["TestField"]) as cursor: for row in cursor: print row[0]
Setters and Getters allow for an object to contain private variables which can be accessed and changed with restrictions. For example, public class Person { private String name; public String getName() { return name; } public void setName(String name) { i...
In general, IBOutlets are used to connect an user interface object to another object, in this case a UIViewController. The connection serves to allow for the object to be affected my code or events programmatically. This can be done simply by using the assistant from a storyboard and control-clickin...
If the shift count value is a negative value then both left shift and right shift operations are undefined1: int x = 5 << -3; /* undefined */ int x = 5 >> -3; /* undefined */ If left shift is performed on a negative value, it's undefined: int x = -5 << 3; /* undefined */ I...

Page 77 of 161