Tutorial by Examples: e

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...
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...
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'; /...
There are multiple ways of adding data to a object in fxml: <property> tag A tag with the name of a property can be added as child of an element used for creating a instance. The child of this tag is assigned to the property using the setter or added to the contents of the property (readonly...
Hi everyone! This is a demo I love running for people that get started with BigQuery. So let's run some simple queries to get you started. Setup You will need a Google Cloud project: Go to http://bigquery.cloud.google.com/. If it tells you to create a project, follow the link to create a proje...
RxSwift provides not only the ways to control your data, but to represent user actions in a reactive way also. RxCocoa contains everything you need. It wraps most of the UI components' properties into Observables, but not really. There are some upgraded Observables called ControlEvents (which repre...

Page 641 of 1191