Tutorial by Examples

Quintile analysis is a common framework for evaluating the efficacy of security factors. What is a factor A factor is a method for scoring/ranking sets of securities. For a particular point in time and for a particular set of securities, a factor can be represented as a pandas series where the in...
This creates a variant (a tagged union) that can store either an int or a string. std::variant< int, std::string > var; We can store one of either type in it: var = "hello"s; And we can access the contents via std::visit: // Prints "hello\n": visit( [](auto&&a...
This is an advanced example. You can use variant for light weight type erasure. template<class F> struct pseudo_method { F f; // enable C++17 class type deduction: pseudo_method( F&& fin ):f(std::move(fin)) {} // Koenig lookup operator->*, as this is a pseudo-method...
This does not cover allocators. struct A {}; struct B { B()=default; B(B const&)=default; B(int){}; }; struct C { C()=delete; C(int) {}; C(C const&)=default; }; struct D { D( std::initializer_list<int> ) {}; D(D const&)=default; D()=default; }; std::variant<A,B> var_ab...
Lambda Expresions are an extension of anonymous methods that allow for implicitly typed parameters and return values. Their syntax is less verbose than anonymous methods and follows a functional programming style. using System; using System.Collections.Generic; using System.Linq; ...
Run go test as normal, yet with the coverprofile flag. Then use go tool to view the results as HTML. go test -coverprofile=c.out go tool cover -html=c.out
C99 C99 introduced the concept of designated initializers. These allow you to specify which elements of an array, structure or union are to be initialized by the values following. Designated initializers for array elements For a simple type like plain int: int array[] = { [4] = 29, [5] = 31, [1...
Calculating the factorial of a number is a classic example of a recursive function. Missing the Base Condition: #include <stdio.h> int factorial(int n) { return n * factorial(n - 1); } int main() { printf("Factorial %d = %d\n", 3, factorial(3)); return 0;...
With IpRateLimit middleware you can set multiple limits for different scenarios like allowing an IP or IP range to make a maximum number of calls in a time interval like per second, 15 minutes, etc. You can define these limits to address all requests made to an API or you can scope the limits to eac...
With ClientRateLimit middleware you can set multiple limits for different scenarios like allowing a Client to make a maximum number of calls in a time interval like per second, 15 minutes, etc. You can define these limits to address all requests made to an API or you can scope the limits to each URL...
8 The Object.values() method returns an array of a given object's own enumerable property values, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well). var obj = { 0: 'a', 1: 'b', 2: 'c' }; console.log...
To add a Swipe To Refresh layout with a RecyclerView add the following to your Activity/Fragment layout file: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/refresh_layout" android:layout_width="match_parent" android:layout_height="match_pa...
Increment by var a = 9, b = 3; b += a; b will now be 12 This is functionally the same as b = b + a; Decrement by var a = 9, b = 3; b -= a; b will now be 6 This is functionally the same as b = b - a; Multiply by var a = 5, b = 3; b *= a; b will now...
Show curl version: curl --version GET a remote resource and have it displayed in the terminal: curl http://stackoverflow.com GET a remote resource and save it in a local file: curl -o file https://stackoverflow.com Add headers to response: curl -i http://stackoverflow.com Output only...
The original C standard had no intrinsic Boolean type, so bool, true and false had no inherent meaning and were often defined by programmers. Typically true would be defined as 1 and false would be defined as 0. C99 C99 adds the built-in type _Bool and the header <stdbool.h> which defines bo...
It is unlikely that someone uses an unsupported version of Django, and at his own risks. If ever someone does, it must be his concern to know if a feature exists in the given version. Considering the above, it is useless to mention specificities of an unsupported version. 1.6 This kind of block i...
In modern browsers [1], it is possible to use CSS-like selector to query for elements in a document -- the same way as sizzle.js (used by jQuery). querySelector Returns the first Element in the document that matches the query. If there is no match, returns null. // gets the element whose id=&quot...
What is JNA? Java Native Access (JNA) is a community-developed library providing Java programs an easy access to native shared libraries (.dll files on windows, .so files on Unix ...) How can I use it? Firstly, download the latest release of JNA and reference its jna.jar in your project's CLA...
It's possible to write directly to the rendered image data using putImageData. By creating new image data then assigning it to the canvas, you will clear the entire screen. var imageData = ctx.createImageData(canvas.width, canvas.height); ctx.putImageData(imageData, 0, 0); Note: putImageData is...
It's possible to clear complex shaped regions by changing the globalCompositeOperation property. // All pixels being drawn will be transparent ctx.globalCompositeOperation = 'destination-out'; // Clear a triangular section ctx.globalAlpha = 1; // ensure alpha is 1 ctx.fillStyle = '#000'; /...

Page 726 of 1336