Tutorial by Examples: er

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...
So far, we have looked at inserting a node at the beginning of a singly linked list. However, most of the times you will want to be able to insert nodes elsewhere as well. The code written below shows how it is possible to write an insert() function to insert nodes anywhere in the linked lists. #...
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...
To start the process: $ forever start index.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: index.js List running Forever instances: $ forever list i...
If you need to sort the results of a UNION, use this pattern: ( SELECT ... ) UNION ( SELECT ... ) ORDER BY Without the parentheses, the final ORDER BY would belong to the last SELECT.
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...
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...
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...
class ExampleClass { // Access modifiers first (don't do for instance "static public") public static void main(String[] args) { System.out.println("Hello World"); } } interface ExampleInterface { // Avoid 'public' and 'abstract' since they are imp...
long l = 5432L; int i = 0x123 + 0xABC; byte b = 0b1010; float f1 = 1 / 5432f; float f2 = 0.123e4f; double d1 = 1 / 5432d; // or 1 / 5432.0 double d2 = 0x1.3p2; long literals should use the upper case letter L suffix. Hexadecimal literals should use upper case letters A-F. All other num...
var gradient = createRadialGradient( centerX1, centerY1, radius1, // this is the "display' circle centerX2, centerY2, radius2 // this is the "light casting" circle ) gradient.addColorStop(gradientPercentPosition, CssColor) gradient.addColorStop(gradientPerce...
Once you have setup and configured the php5-fpm and wordpress settings you can configure the /etc/nginx/conf/nginx.conf file as below. You need to define the location blocks inside the server block and rewrite the url there as defined. server { listen 443 ssl; server_name abc.co.uk; ...
for /L %%A in (1,2,40) do echo %%A This line will iterate from 1 to 39, increasing by 2 each time. The first parameter, 1, is the starting number. The second parameter, 2, is the increment. The third parameter, 40, is the maximum.
Use itertools.chain to create a single generator which will yield the values from several generators in sequence. from itertools import chain a = (x for x in ['1', '2', '3', '4']) b = (x for x in ['x', 'y', 'z']) ' '.join(chain(a, b)) Results in: '1 2 3 4 x y z' As an alternate constructo...
Fetching resources over the network is both slow and expensive: the download may require multiple roundtrips between the client and server, which delays processing and may block rendering of page content, and also incurs data costs for the visitor. All server responses should specify a caching p...
Arithmetic operators in C++ have the same precedence as they do in mathematics: Multiplication and division have left associativity(meaning that they will be evaluated from left to right) and they have higher precedence than addition and subtraction, which also have left associativity. We can also...
These operators have the usual precedence in C++: AND before OR. // You can drive with a foreign license for up to 60 days bool can_drive = has_domestic_license || has_foreign_license && num_days <= 60; This code is equivalent to the following: // You can drive with a foreign licens...
template< class Iterator > bool next_permutation( Iterator first, Iterator last ); template< class Iterator, class Compare > bool next_permutation( Iterator first, Iterator last, Compare cmpFun ); Effects: Sift the data sequence of the range [first, last) into the next lexicograph...
Passing a pointer argument to a T* parameter, if possible, is better than passing it to a const T* parameter. struct Base {}; struct Derived : Base {}; void f(Base* pb); void f(const Base* pb); void f(const Derived* pd); void f(bool b); Base b; f(&b); // f(Base*) is better than f(const...
java -jar [Path to client JAR] -s [Server address] install-plugin [Plugin ID] The client JAR must be the CLI JAR file, not the same JAR/WAR that runs Jenkins itself. Unique IDs can be found on a plugins respective page on the Jenkins CLI wiki (https://wiki.jenkins-ci.org/display/JENKINS/Plugins) ...

Page 165 of 417