Tutorial by Examples: c

package com.example.my.package; The package declaration should not be line wrapped, regardless of whether it exceeds the recommended maximum length of a line.
Order of class members Class members should be ordered as follows: Fields (in order of public, protected and private) Constructors Factory methods Other Methods (in order of public, protected and private) Ordering fields and methods primarily by their access modifiers or identifier is not ...
int someMethod(String aString, List<Integer> aList, Map<String, String> aMap, int anInt, long aLong, Set<Number> aSet, double aDouble) { … } int someMethod(String aString, List&...
Vertical Whitespace A single blank line should be used to separate… Package declaration Class declarations Constructors Methods Static initializers Instance initializers …and may be used to separate logical groups of import statements fields statements Multiple consec...
One variable per declaration (and at most one declaration per line) Square brackets of arrays should be at the type (String[] args) and not on the variable (String args[]). Declare a local variable right before it is first used, and initialize it as close to the declaration as possible.
In this example, a function map named funcMap is supplied to the template via the Funcs() method and then invoked inside the template. Here, the function increment() is used to get around the lack of a less than or equal function in the templating language. Note in the output how the final item in t...
Note how field values are obtained using {{.FieldName}}. package main import ( "fmt" "os" "text/template" ) type Person struct { FirstName string LastName string Street string City string State string Zip...
First, here's what can happen when text/template is used for HTML. Note Harry's FirstName property). package main import ( "fmt" "html/template" "os" ) type Person struct { FirstName string LastName string Street string Cit...
Using regular recursion, each recursive call pushes another entry onto the call stack. When the recursion is completed, the application has to pop each entry off all the way back down. If there are much recursive function calls it can end up with a huge stack. Scala automatically removes the recurs...
Methods in Go are just like functions, except they have receiver. Usually receiver is some kind of struct or type. package main import ( "fmt" ) type Employee struct { Name string Age int Rank int } func (empl *Employee) Promote() { empl.Rank++ } ...
With methods in golang you can do method "chaining" passing pointer to method and returning pointer to the same struct like this: package main import ( "fmt" ) type Employee struct { Name string Age int Rank int } func (empl *Employee) Promote() *...
context.lineCap=capStyle // butt (default), round, square Sets the cap style of line starting points and ending points. butt, the default lineCap style, shows squared caps that do not extend beyond the line's starting and ending points. round, shows rounded caps that extend beyond the ...
shadowColor = color // CSS color shadowBlur = width // integer blur width shadowOffsetX = distance // shadow is moved horizontally by this offset shadowOffsetY = distance // shadow is moved vertically by this offset This set of attributes will add a shadow around a path. Bo...
var gradient = createLinearGradient( startX, startY, endX, endY ) gradient.addColorStop(gradientPercentPosition, CssColor) gradient.addColorStop(gradientPercentPosition, CssColor) [optionally add more color stops to add to the variety of the gradient] Creates a reusable linear gradient (object...
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; ...
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...
import std.stdio; T min(T)(in T arg1, in T arg2) { return arg1 < arg2 ? arg1 : arg2; } void main() { //Automatic type inference writeln(min(1, 2)); //Explicit type writeln(min!(ubyte)(1, 2)); //With single type, the parenthesis might be ommited ...
package main import ( "fmt" "net/http" "os" "text/template" ) var requestTemplate string = ` {{range $i, $url := .URLs}} {{ $url }} {{(status_code $url)}} {{ end }}` type Requests struct { URLs []string } func main() {...
You can check for syntax errors and referenced files in an NGINX configuration file before running it with: nginx -t Alternatively you can run service script service nginx configtest While both of these commands will tell you if your new nginx configuration is ok [without killing your curren...

Page 323 of 826