Tutorial by Examples

As of Java 8, there are default methods on the Map.Entry interface to allow sorting of map iterations. Java SE 8 Map<String, Integer> numberOfEmployees = new HashMap<>(); numberOfEmployees.put("executives", 10); numberOfEmployees.put("human ressources", 32); numb...
MySQL provides the following arithmetic operators OperatorNameExample+AdditionSELECT 3+5; -> 8 SELECT 3.5+2.5; -> 6.0 SELECT 3.5+2; -> 5.5-SubtractionSELECT 3-5; -> -2*MultiplicationSELECT 3 * 5; -> 15/DivisionSELECT 20 / 4; -> 5 SELECT 355 / 113; -> 3.1416 SELECT 10.0 / 0; -...
Pi The following returns the value of PI formatted to 6 decimal places. The actual value is good to DOUBLE; SELECT PI(); -> 3.141593
Angles are in Radians, not Degrees. All computations are done in IEEE 754 64-bit floating point. All floating point computations are subject to small errors, known as machine ε (epsilon) errors, so avoid trying to compare them for equality. There is no way to avoid these errors when using floating p...
Round a decimal number to an integer value For exact numeric values (e.g. DECIMAL): If the first decimal place of a number is 5 or higher, this function will round a number to the next integer away from zero. If that decimal place is 4 or lower, this function will round to the next integer value cl...
To raise a number x to a power y, use either the POW() or POWER() functions SELECT POW(2,2); => 4 SELECT POW(4,2); => 16
Use the SQRT() function. If the number is negative, NULL will be returned SELECT SQRT(16); -> 4 SELECT SQRT(-3); -> NULL
Generate a random number To generate a pseudorandom floating point number between 0 and 1, use the RAND() function Suppose you have the following query SELECT i, RAND() FROM t; This will return something like this iRAND()10.619143887068220.9384516830914230.83482678498591 Random Number in a r...
Return the absolute value of a number SELECT ABS(2); -> 2 SELECT ABS(-46); -> 46 The sign of a number compares it to 0. SignResultExample-1n < 0SELECT SIGN(42); -> 10n = 0SELECT SIGN(0); -> 01n > 0SELECT SIGN(-3); -> -1 SELECT SIGN(-423421); -> -1
Mixins are a sort of class that is used to "mix in" extra properties and methods into a class. This is usually fine because many times the mixin classes don't override each other's, or the base class' methods. But if you do override methods or properties in your mixins this can lead to une...
To install and load the current stable version of ggplot2 for your R installation use: # install from CRAN install.packages("ggplot2") To install the development version from github use # install.packages("devtools") devtools::install_github("hadley/ggplot2") ...
public class ConnectSocketExample { private int HTTP_PORT = 80; /** * example method to create unconnected socket * then connect to it * at end return connected socket * * @param httpHostName - endpoint host name fot socket connection * @throws IOEx...
/** * we reuse a class written in example: * http://stackoverflow.com/documentation/sockets/2876/introduction-to-sockets#t=201607262114505531351 * pleas to familiar with it first to continue with this one **/ public class WriteToSocketExample extends ConnectSocketExample { private ...
A macro is a series of keystrokes meant to be "played back" by Vim without any delay. Macros can be stored in registers or variables, bound to keys, or executed on the command line. Here is a simple macro that uppercases the third word on a line: 0wwgUiw That macro could be recorded i...
/** * Explain briefly what method does here * @param x Explain briefly what should be x and how this affects the method. * @param y Explain briefly what should be y and how this affects the method. * @return Explain what is returned from execution. */ def method(x: Int, y: String): O...
As ES6 introduced Symbols, which are both unique and immutable primitive values that may be used as the key of an Object property, instead of using strings as possible values for an enum, it's possible to use symbols. // Simple symbol const newSymbol = Symbol(); typeof newSymbol === 'symbol' // t...
5.1 This Example demonstrates how to automatically assign a value to each entry in an enum list. This will prevent two enums from having the same value by mistake. NOTE: Object.freeze browser support var testEnum = function() { // Initializes the enumerations var enumList = [ &q...
The SilverStripe CMS can be customised to change the CMS logo, link and application name. This can be achieved with the following config.yml settings LeftAndMain: application_name: 'My Application' application_link: 'http://www.example.com/' extra_requirements_css: - mysite/css/cms.c...
import java.util.Scanner; Scanner s = new Scanner(System.in); int number = s.nextInt(); If you want to read an int from the command line, just use this snippet. First of all, you have to create a Scanner object, that listens to System.in, which is by default the Command Line, when you start ...
SpriteKit functionality can be implemented in a subclass of SKScene. For example, a game may implement the main game functionality within an SKScene subclass called GameScene. In Swift: import SpriteKit class GameScene: SKScene { override func didMoveToView(view: SKView) { /* Co...

Page 611 of 1336