Tutorial by Examples: c

package main import ( "log" "text/template" "os" ) type Person struct{ MyName string MyAge int } var myTempContents string= ` This person's name is : {{.MyName}} And he is {{.MyAge}} years old. ` func main() { t,err := temp...
To assign variables from the command-line, -v can be used: $ awk -v myvar="hello" 'BEGIN {print myvar}' hello Note that there are no spaces around the equal sign. This allows to use shell variables: $ shell_var="hello" $ awk -v myvar="$shell_var" 'BEGIN {print m...
Rcpp features two functions that enable code compilation inline and exportation directly into R: cppFunction() and evalCpp(). A third function called sourceCpp() exists to read in C++ code in a separate file though can be used akin to cppFunction(). Below is an example of compiling a C++ function w...
Rcpp Attributes makes the process of working with R and C++ straightforward. The form of attributes take: // [[Rcpp::attribute]] The use of attributes is typically associated with: // [[Rcpp::export]] that is placed directly above a declared function header when reading in a C++ file via sou...
Within C++, one can set different compilation flags using: // [[Rcpp::plugins(name)]] List of the built-in plugins: // built-in C++11 plugin // [[Rcpp::plugins(cpp11)]] // built-in C++11 plugin for older g++ compiler // [[Rcpp::plugins(cpp0x)]] // built-in C++14 plugin for C++14 standa...
In some cases you may want to wrap a synchronous operation inside a promise to prevent repetition in code branches. Take this example: if (result) { // if we already have a result processResult(result); // process it } else { fetchResult().then(processResult); } The synchronous and async...
Cloning a huge repository (like a project with multiple years of history) might take a long time, or fail because of the amount of data to be transferred. In cases where you don't need to have the full history available, you can do a shallow clone: git clone [repo_url] --depth 1 The above comman...
Similarly to the SimpleXML, you can use DOMDocument to parse XML from a string or from a XML file 1. From a string $doc = new DOMDocument(); $doc->loadXML($string); 2. From a file $doc = new DOMDocument(); $doc->load('books.xml');// use the actual file path. Absolute or relative Exa...
When you want to use user generated content in the SQL, it with done with parameters. For example for searching user with the name aminadav you should do: var username = 'aminadav'; var querystring = 'SELECT name, email from users where name = ?'; connection.query(querystring, [username], functi...
a. Running multiple queries at same time All queries in MySQL connection are done one after another. It means that if you want to do 10 queries and each query takes 2 seconds then it will take 20 seconds to complete whole execution. The solution is to create 10 connection and run each query in a di...
One of the easiest ways to connect to MySQL is by using mysql module. This module handles the connection between Node.js app and MySQL server. You can install it like any other module: npm install --save mysql Now you have to create a mysql connection, which you can later query. const mysql ...
You send the query as a string and in response callback with the answer is received. The callback gives you error, array of rows and fields. Each row contains all the column of the returned table. Here is a snippet for the following explanation. connection.query('SELECT name,email from users', fu...
git checkout --orphan new-orphan-branch The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits. source
You may define scripts in your package.json, for example: { "name": "your-package", "version": "1.0.0", "description": "", "main": "index.js", "author": "", "license": &qu...
You can use a RecyclerView.ItemDecoration to put extra margins around each item in a RecyclerView. This can in some cases clean up both your adapter implementation and your item view XML. public class MyItemDecoration extends RecyclerView.ItemDecoration { private final int extraMargin; ...
You can group multiple boolean logic statements within parenthesis in order to create a more complex logic evaluation, especially useful in if statements. if ((age >= 18 && height >= 5.11) || (status === 'royalty' && hasInvitation)) { console.log('You can enter our club'); ...
__call() and __callStatic() are called when somebody is calling nonexistent object method in object or static context. class Foo { /** * This method will be called when somebody will try to invoke a method in object * context, which does not exist, like: * * $foo->...
__clone is invoked by use of the clone keyword. It is used to manipulate object state upon cloning, after the object has been actually cloned. class CloneableUser { public $name; public $lastName; /** * This method will be invoked by a clone operator and will prepend "C...
Blade provides convenient syntax for common PHP control structures. Each of the control structures begins with @[structure] and ends with @[endstructure]. Notice that within the tags, we are just typing normal HTML and including variables with the Blade syntax. Conditionals 'If' statements @if...
Any PHP expression within double curly braces {{ $variable }} will be echoed after being run through the e helper function. (So html special characters (<, >, ", ', &) are safely replaced for the corresponding html entities.) (The PHP expression must evaluate to string, otherwise an ...

Page 107 of 826