Tutorial by Examples: c

.SD .SD refers to the subset of the data.table for each group, excluding all columns used in by. .SD along with lapply can be used to apply any function to multiple columns by group in a data.table We will continue using the same built-in dataset, mtcars: mtcars = data.table(mtcars) # Let's not ...
SyncAdapter /** * Define a sync adapter for the app. * <p/> * <p>This class is instantiated in {@link SyncService}, which also binds SyncAdapter to the system. * SyncAdapter should only be initialized in SyncService, never anywhere else. * <p/> * <p>The system ca...
Sometimes it is appropriate to use an immutable empty collection. The Collections class provides methods to get such collections in an efficient way: List<String> anEmptyList = Collections.emptyList(); Map<Integer, Date> anEmptyMap = Collections.emptyMap(); Set<Number> anEmptySe...
In Julia, the @show macro is often useful for debugging purposes. It displays both the expression to be evaluated and its result, finally returning the value of the result: julia> @show 1 + 1 1 + 1 = 2 2 It is straightforward to create our own version of @show: julia> macro myshow(exp...
A pure function is a function that, given the same input, will always return the same output and are side-effect free. // This is a pure function function add($a, $b) { return $a + $b; } Some side-effects are changing the filesystem, interacting with databases, printing to the screen. //...
Partial credit to this SO answer. List Concatenation aggregates a column or expression by combining the values into a single string for each group. A string to delimit each value (either blank or a comma when omitted) and the order of the values in the result can be specified. While it is not part ...
When running from the CLI, PHP exhibits some different behaviours than when run from a web server. These differences should be kept in mind, especially in the case where the same script might be run from both environments. No directory change When running a script from a web server, the current w...
The INITCAP function converts the case of a string so that each word starts with a capital letter and all subsequent letters are in lowercase. SELECT INITCAP('HELLO mr macdonald!') AS NEW FROM dual; Output NEW ------------------- Hello Mr Macdonald!
Dynamic binding, also referred as method overriding is an example of run time polymorphism that occurs when multiple classes contain different implementations of the same method, but the object that the method will be called on is unknown until run time. This is useful if a certain condition dicta...
The @var keyword can be used to describe the type and usage of: a class property a local or global variable a class or global constant class Example { /** @var string This is something that stays the same */ const UNCHANGING = "Untouchable"; /** @var string $some_s...
void doSomething(String... strings) { for (String s : strings) { System.out.println(s); } } The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments. Varargs can be used only in the final argume...
Builtin container comes with a set of builtin features : Lifetime control public void ConfigureServices(IServiceCollection services) { // ... services.AddTransient<ITestService, TestService>(); // or services.AddScoped<ITestService, TestSer...
Once registered a dependency can be retrieved by adding parameters on the Controller constructor. // ... using System; using Microsoft.Extensions.DependencyInjection; namespace Core.Controllers { public class HomeController : Controller { public HomeController(ITestServic...
Named functions function multiply(a, b) { return a * b; } Anonymous functions let multiply = function(a, b) { return a * b; }; Lambda / arrow functions let multiply = (a, b) => { return a * b; };
It's possible to create a new ASP.NET Core project entirely from the command line using the dotnet command. dotnet new web dotnet restore dotnet run dotnet new web scaffolds a new "empty" web project. The web parameter tells the dotnet tool to use the ASP.NET Core Empty template. Use...
Records are an extension of sum algebraic data type that allow fields to be named: data StandardType = StandardType String Int Bool --standard way to create a sum type data RecordType = RecordType { -- the same sum type with record syntax aString :: String , aNumber :: Int , isTrue :...
With C++11 and higher calculations at compile time can be much easier. For example calculating the power of a given number at compile time will be following: template <typename T> constexpr T calculatePower(T value, unsigned power) { return power == 0 ? 1 : value * calculatePower(value,...
Access ModifierVisibilityInheritancePrivateClass onlyCan't be inheritedNo modifier / PackageIn packageAvailable if subclass in packageProtectedIn packageAvailable in subclassPublicEverywhereAvailable in subclass There was once a private protected (both keywords at once) modifier that could be appli...
Here is how to make a Heads Up Notification for capable devices, and use a Ticker for older devices. // Tapping the Notification will open up MainActivity Intent i = new Intent(this, MainActivity.class); // an action to use later // defined as an app constant: // public static final String ME...
Using Razor @functions keyword gives the capability of introducing classes and methods for inline use within a Razor file: @functions { string GetCssClass(Status status) { switch (status) { case Status.Success: return "alert-success&qu...

Page 148 of 826