Tutorial by Examples: er

Suppose we have a plain object called prototype: var prototype = { foo: 'foo', bar: function () { return this.foo; } }; Now we want another object called obj that inherits from prototype, which is the same as saying that prototype is the prototype of obj var obj = Object.create(prototype); N...
This example uses the Dropbox .NET library to try to get the metadata for an item at a particular path, and checks for a NotFound error: try { var metadata = await this.client.Files.GetMetadataAsync("/non-existant path"); Console.WriteLine(metadata.Name); } catch (Dropbox.Api.A...
Property injection allows a classes dependencies to be updated after it has been created. This can be useful if you want to simplify object creation, but still allow the dependencies to be overridden by your tests with test doubles. Consider a class that needs to write to a log file in an error co...
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 ...
C++14 Lambdas can capture expressions, rather than just variables. This permits lambdas to store move-only types: auto p = std::make_unique<T>(...); auto lamb = [p = std::move(p)]() //Overrides capture-by-value of `p`. { p->SomeFunc(); }; This moves the outer p variable into th...
If you precede a local variable's name with an &, then the variable will be captured by reference. Conceptually, this means that the lambda's closure type will have a reference variable, initialized as a reference to the corresponding variable from outside of the lambda's scope. Any use of the v...
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...
> mysqldump -u username -p [other options] Enter password: If you need to specify the password on the command line (e.g. in a script), you can add it after the -p option without a space: > mysqldump -u username -ppassword [other options] If you password contains spaces or special chara...
c++14 Lambda functions can take arguments of arbitrary types. This allows a lambda to be more generic: auto twice = [](auto x){ return x+x; }; int i = twice(2); // i == 4 std::string s = twice("hello"); // s == "hellohello" This is implemented in C++ by making the closur...
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 = ...
In older browsers where Date.now() is unavailable, use (new Date()).getTime() instead: t = (new Date()).getTime(); Or, to provide a Date.now() function for use in older browsers, use this polyfill: if (!Date.now) { Date.now = function now() { return new Date().getTime(); }; }
C++11 A std::unique_ptr is a class template that manages the lifetime of a dynamically stored object. Unlike for std::shared_ptr, the dynamic object is owned by only one instance of a std::unique_ptr at any time, // Creates a dynamic int with value of 20 owned by a unique pointer std::unique_pt...
Bosun notifications are assigned to alert definitions using warnNotification and critNotification and indicate where to send the rendered alert template when a new incident occur. Notifications can be sent via email or use HTTP GET/POST requests. There also is a Print notification that just adds inf...
The extension method to be called is determined at compile-time based on the reference-type of the variable being accessed. It doesn't matter what the variable's type is at runtime, the same extension method will always be called. open class Super class Sub : Super() fun Super.myExtension()...
CREATE TABLE MyTableName ( Id INT, MyColumnName NVARCHAR(1000) ) GO INSERT INTO MyTableName (Id, MyColumnName) VALUES (1, N'Hello World!') GO
When an API is marked with NS_REFINED_FOR_SWIFT, it will be prefixed with two underscores (__) when imported to Swift: @interface MyClass : NSObject - (NSInteger)indexOfObject:(id)obj NS_REFINED_FOR_SWIFT; @end The generated interface looks like this: public class MyClass : NSObject { publ...
PM> Install-Package EntityFramework -Version 6.1.2
// Check if service worker is available. if ('serviceWorker' in navigator) { navigator.serviceWorker.register('/sw.js').then(function(registration) { console.log('SW registration succeeded with scope:', registration.scope); }).catch(function(e) { console.log('SW registration failed...
In this case, building against API 23, so permissions are handled too. You must add in the Manifest the following permission (wherever the API level you're using): <uses-permission android:name="android.permission.CAMERA"/> We're about to create an activity (Camera2Activity.java...
In this example, we can use GROUP BY not only determined the sort of the rows returned, but also what rows are returned, since we're using TOP to limit the result set. Let's say we want to return the top 5 highest reputation users from an unnamed popular Q&A site. Without ORDER BY This query ...

Page 25 of 417