Tutorial by Examples: er

8 The proposed Object.entries() method returns an array of key/value pairs for the given object. It does not return an iterator like Array.prototype.entries(), but the Array returned by Object.entries() can be iterated regardless. const obj = { one: 1, two: 2, three: 3 }; Object...
In order for a program to react to a certain signal, other than using default action, custom signal handler can be installed using sigaction. sigaction receives three arguments - signal to act on, pointer to sigaction_t structure which, if not NULL, is describing new behaviour and pointer to sigacti...
When rendering a form 'by hand', it can be useful to know if there are fields left to render or not. The function isRendered() from the FormView class returns true if there are still fields left to be rendered to the template. This snippet prints <h3>Extra fields</h3> if there are fiel...
There are dozens of character sets with hundreds of collations. (A given collation belongs to only one character set.) See the output of SHOW COLLATION;. There are usually only 4 CHARACTER SETs that matter: ascii -- basic 7-bit codes. latin1 -- ascii, plus most characters needed for Western Eur...
Use git revert to revert existing commits, especially when those commits have been pushed to a remote repository. It records some new commits to reverse the effect of some earlier commits, which you can push safely without rewriting history. Don't use git push --force unless you wish to bring down ...
C++ thrives on what is known as a Regular type (or at least Pseudo-Regular). A Regular type is a type that can be constructed and assigned-to and assigned-from via copy or move, can be destroyed, and can be compared equal-to. It can also be constructed from no arguments. Finally, it also has supp...
As a developer, you frequently find yourself dealing with strings that are not created by your own code. These will often be supplied by third party libraries, external systems, or even end users. Validating strings of unclear provenance is considered to be one of the hallmarks of defensive program...
Pattern synonyms are abstractions of patterns similar to how functions are abstractions of expressions. For this example, let's look at the interface Data.Sequence exposes, and let's see how it can be improved with pattern synonyms. The Seq type is a data type that, internally, uses a complicated r...
A real world example using a scientific experiment where certain routines are performed on different types of tissue. The class contains two functions by default to get the tissue or routine separately. In a later version we have then adapted it using a new class to add a function that gets both. Th...
Visitor pattern allows you to add new operations or methods to a set of classes without modifying the structure of those classes. This pattern is especially useful when you want to centralise a particular operation on an object without extending the object Or without modifying the object. UML diag...
Lets assume that in your current codebase, there exists MyLogger interface like so: interface MyLogger { void logMessage(String message); void logException(Throwable exception); } Lets say that you've created a few concrete implementations of these, such as MyFileLogger and MyConsol...
The yield keyword allows lazy-evaluation of the collection. Forcibly loading the whole collection into memory is called eager evaluation. The following code shows this: IEnumerable<int> myMethod() { for(int i=0; i <= 8675309; i++) { yield return i; } } ... // ...
A cached query is a query that has its results stored in the server's memory. The results are stored when the query is first run. From then on, whenever that query is requested again, ColdFusion will retrieve the results from memory. You can cache a query using the cachedAfter attribute. If the que...
You can limit the number of rows to be returned by using the maxrows attribute. <cfquery datasource="Entertainment" maxrows="50"> select * from Movies </cfquery>
If you want to make internal classes or functions of an assembly accessable from another assembly you declare this by InternalsVisibleTo and the assembly name that is allowed to access. In this example code in the assembly MyAssembly.UnitTests is allowed to call internal elements from MyAssembly. ...
Structures can be made generic over one or more type parameters. These types are given enclosed in <> when referring to the type: struct Gen<T> { x: T, z: isize, } // ... let _: Gen<bool> = Gen{x: true, z: 1}; let _: Gen<isize> = Gen{x: 42, z: 2}; let _: Gen...
C.I.A.s are intended as a simple way of getting attributes from whatever is calling the targeted method. There is really only 1 way to use them and there are only 3 attributes. Example: //This is the "calling method": the method that is calling the target method public void doProcess() ...
Write-Host "Hello World" Introduction to PowerShell
System.Console.WriteLine("Hello World");
Android Studio's Live templates can offer quite a few shortcuts for quick logging. To use Live templates, all you need to do is to start typing the template name, and hit TAB or enter to insert the statement. Examples: logi → turns into → android.util.Log.i(TAG, "$METHOD_NAME$: $content$&q...

Page 197 of 417