Tutorial by Examples: c

There are times when an include file has to generate different output from the preprocessor depending on whether the compiler is a C compiler or a C++ compiler due to language differences. For example a function or other external is defined in a C source file but is used in a C++ source file. Since...
A common problem in code that uses multidimensional arrays, arrays of pointers, etc. is the fact that Type** and Type[M][N] are fundamentally different types: #include <stdio.h> void print_strings(char **strings, size_t n) { size_t i; for (i = 0; i < n; i++) puts(str...
When allocating multidimensional arrays with malloc, calloc, and realloc, a common pattern is to allocate the inner arrays with multiple calls (even if the call only appears once, it may be in a loop): /* Could also be `int **` with malloc used to allocate outer array. */ int *array[4]; int i; ...
There's no built in way to search a list for a particular item. However Programming in Lua shows how you might build a set that can help: function Set (list) local set = {} for _, l in ipairs(list) do set[l] = true end return set end Then you can put your list in the Set and test for m...
Objective-C UIColor *color = [UIColor redColor]; NSString *textToFind = @"redword"; NSMutableAttributedString *attrsString = [[NSMutableAttributedString alloc] initWithAttributedString:yourLabel.attributedText]; // search for word occurrence NSRange range = [yourLabel.text rangeO...
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <executions> <execution> <...
To be able to debug an application is very important to understand the flow of an application's logic and data. It helps solving logical bugs and adds value to the programming experience and code quality. Two popular gems for debugging are debugger (for ruby 1.9.2 and 1.9.3) and byebug (for ruby &g...
com.google.gson library needs to be added to use this code. Here is the example string: String companyDetails = {"companyName":"abcd","address":"abcdefg"} JSON strings can be parsed using below syntax in Java: JsonParser parser = new JsonParser(); Json...
The word count program is like the "Hello World" program in MapReduce. Hadoop MapReduce is a software framework for easily writing applications which process vast amounts of data (multi-terabyte data-sets) in-parallel on large clusters (thousands of nodes) of commodity hardware in a relia...
PM2 lets you run your nodejs scripts forever. In the event that your application crashes, PM2 will also restart it for you. Install PM2 globally to manager your nodejs instances npm install pm2 -g Navigate to the directory in which your nodejs script resides and run the following command each t...
Strict mode also prevents you from deleting undeletable properties. "use strict"; delete Object.prototype; // throws a TypeError The above statement would simply be ignored if you don't use strict mode, however now you know why it does not execute as expected. It also prevents you fr...
Remember to npm install all the files into devDependencies first. E.g. npm install --save-dev gulp gulp-concat gulp-rename gulp-uglify gulp-uglifycss Gulpfile.js var gulp = require('gulp'); var gulp_concat = require('gulp-concat'); var gulp_rename = require('gulp-rename'); var gulp_uglify = ...
To create a parallel collection from a sequential collection, call the par method. To create a sequential collection from a parallel collection, call the seq method. This example shows how you turn a regular Vector into a ParVector, and then back again: scala> val vect = (1 to 5).toVector vect:...
The most common mode of using TensorFlow involves first building a dataflow graph of TensorFlow operators (like tf.constant() and tf.matmul(), then running steps by calling the tf.Session.run() method in a loop (e.g. a training loop). A common source of memory leaks is where the training loop conta...
To improve memory allocation performance, many TensorFlow users often use tcmalloc instead of the default malloc() implementation, as tcmalloc suffers less from fragmentation when allocating and deallocating large objects (such as many tensors). Some memory-intensive TensorFlow programs have been kn...
There are several scopes that are available only in a web-aware application context: request - new bean instance is created per HTTP request session - new bean instance is created per HTTP session application - new bean instance is created per ServletContext globalSession - new bean instance i...
When using async queries, you can execute multiple queries at the same time, but not on the same context. If the execution time of one query is 10s, the time for the bad example will be 20s, while the time for the good example will be 10s. Bad Example IEnumerable<TResult1> result1; IEnumera...
In [188]: s = pd.Series(["a","b","c","a","c"], dtype="category") In [189]: s Out[189]: 0 a 1 b 2 c 3 a 4 c dtype: category Categories (3, object): [a, b, c] In [190]: df = pd.DataFrame({"A":["a&q...
All lines must be terminated with a line feed character (LF, ASCII value 10) and not for instance CR or CR+LF. There may be no trailing white space at the end of a line. The name of a source file must equal the name of the class it contains followed by the .java extension, even for fil...
Apart from LF the only allowed white space character is Space (ASCII value 32). Note that this implies that other white space characters (in, for instance, string and character literals) must be written in escaped form. \', \", \\, \t, \b, \r, \f, and \n should be preferred over corres...

Page 322 of 826