Tutorial by Examples: c

Since npm itself is a Node.js module, it can be updated using itself. If OS is Windows must be running command prompt as Admin npm install -g npm@latest If you want to check for updated versions you can do: npm outdated In order to update a specific package: npm update <package name>...
Removing duplicate values in a list can be done by converting the list to a set (that is an unordered collection of distinct objects). If a list data structure is needed, then the set can be converted back to a list using the function list(): names = ["aixk", "duke", "edik&...
A closure is the PHP equivalent of an anonymous function, eg. a function that does not have a name. Even if that is technically not correct, the behavior of a closure remains the same as a function's, with a few extra features. A closure is nothing but an object of the Closure class which is create...
As seen previously, a closure is nothing but an instance of the Closure class, and different methods can be invoked on them. One of them is bindTo, which, given a closure, will return a new one that is bound to a given object. For example: <?php $myClosure = function() { echo $this->p...
Let's consider this example: <?php $myClosure = function() { echo $this->property; }; class MyClass { public $property; public function __construct($propertyValue) { $this->property = $propertyValue; } } $myInstance = new MyClass('Hello world...
Since PHP7, it is possible to bind a closure just for one call, thanks to the call method. For instance: <?php class MyClass { private $property; public function __construct($propertyValue) { $this->property = $propertyValue; } } $myClosure = function() ...
In general, an observer is a class with a specific method being called when an action on the observed object occurs. In certain situations, closures can be enough to implement the observer design pattern. Here is a detailed example of such an implementation. Let's first declare a class whose purpos...
This example creates a simple 1-column repeater that displays a list of numbers, one per repeater item. Markup: <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <%# Container.DataItem.ToString() %> </ItemTemplate> </Repe...
Even though Python natively supports big integers, taking the nth root of very large numbers can fail in Python. x = 2 ** 100 cube = x ** 3 root = cube ** (1.0 / 3) OverflowError: long int too large to convert to float When dealing with such large integers, you will need to use a custom f...
git is fundamentally a key-value store. When you add data to git, it builds an object and uses the SHA-1 hash of the object's contents as a key. Therefore, any content in git can be looked up by it's hash: git cat-file -p 4bb6f98 There are 4 types of Object: blob tree commit tag
A commit is probably the object type most familiar to git users, as it's what they are used to creating with the git commit commands. However, the commit does not directly contain any changed files or data. Rather, it contains mostly metadata and pointers to other objects which contain the actual c...
A tree basically represents a folder in a traditional filesystem: nested containers for files or other folders. A tree contains: 0 or more blob objects 0 or more tree objects Just as you can use ls or dir to list the contents of a folder, you can list the contents of a tree object. $ git ca...
A blob contains arbitrary binary file contents. Commonly, it will be raw text such as source code or a blog article. But it could just as easily be the bytes of a PNG file or anything else. If you have the hash of a blob, you can look at it's contents. $ git cat-file -p d429810 package com.exampl...
The git commit command does a few things: Create blobs and trees to represent your project directory - stored in .git/objects Creates a new commit object with your author information, commit message, and the root tree from step 1 - also stored in .git/objects Updates the HEAD ref in .git/HEAD t...
Running git checkout -b <refname> will create a new ref that points to the current commit. $ cat .git/head 1f324a $ git checkout -b TestBranch $ cat .git/refs/heads/TestBranch 1f324a
The non-block do construct looks like integer i do 100, i=1, 5 100 print *, i That is, where the labelled termination statement is not a continue statement. There are various restrictions on the statement that can be used as the termination statement and the whole thing is generally v...
To verify that nvm has been installed, do: command -v nvm which should output 'nvm' if the installation was successful.
Listing available remote versions for installation nvm ls-remote Installing a remote version nvm install <version> For example nvm install 0.10.13
Three methods are provided that offer the ability to strip leading and trailing characters from a string: str.strip, str.rstrip and str.lstrip. All three methods have the same signature and all three return a new string object with unwanted characters removed. str.strip([chars]) str.strip acts o...
To connect using java.sql.DriverManager you need a JDBC url to connect to your database. JDBC urls are database specific, but they are all of the form jdbc:<subprotocol>:<subname> Where <subprotocol> identifies the driver or database (for example postgresql, mysql, firebirdsql,...

Page 204 of 826