Tutorial by Examples: c

/** * 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...
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...
A simple use case it to create an SKScene that exactly fills the SKView. This avoids the need to consider scaling the view to fit or setting a camera to show a part of the scene. The following code assumes an SKView called skView already exists (e.g. as defined in Create a Full Screen SKView using ...
An SKScene has a scaleMode parameter that defines how it will change its size to fit within the SKView it is presented into the SKView if it is not the same size and/or shape. There are four options for scaleMode: AspectFit: the scene is scaled (but not stretched) until it fits within the view. ...
You can place an SKCameraNode into an SKScene to define which part of the scene is shown in the SKView. Think of the SKScene as a 2D world with a camera floating above it: the SKView will show what the camera 'sees'. E.g. the camera could be attached to the main character's sprite to follow the act...
Chaining assignments as part of a var declaration will create global variables unintentionally. For example: (function foo() { var a = b = 0; })() console.log('a: ' + a); console.log('b: ' + b); Will result in: Uncaught ReferenceError: a is not defined 'b: 0' In the above examp...
class SomeClass { public function __invoke($param1, $param2) { // put your code here } } $instance = new SomeClass(); $instance('First', 'Second'); // call the __invoke() method An object with an __invoke method can be used exactly as any other function. The __invoke meth...
Mapping Applying a function to all elements of an array : array_map('strtoupper', $array); Be aware that this is the only method of the list where the callback comes first. Reducing (or folding) Reducing an array to a single value : $sum = array_reduce($numbers, function ($carry, $number) { ...
The following function can be used to get some basic information about the current browser and return it in JSON format. function getBrowserInfo() { var json = "[{", /* The array containing the browser info */ info = [ navigator.userA...
After your service worker is registered, the browser will try to install & later activate the service worker. Install event listener this.addEventListener('install', function(event) { console.log('installed'); }); Caching One can use this install event returned to cache the assets ne...
MySQL offers a number of different numeric types. These can be broken down into GroupTypesInteger TypesINTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINTFixed Point TypesDECIMAL, NUMERICFloating Point TypesFLOAT, DOUBLEBit Value TypeBIT
WebSocket provides a duplex/bidirectional communication protocol over a single TCP connection. the client opens a connection to a server that is listening for a WebSocket request a client connects to a server using a URI. A server may listen to requests from multiple clients. Server Endpoint...
Character escaping is what allows certain characters (reserved by the regex engine for manipulating searches) to be literally searched for and found in the input string. Escaping depends on context, therefore this example does not cover string or delimiter escaping. Backslashes Saying that backsla...
The easiest and quickest way to encode a Haskell data type to JSON with Aeson is using generics. {-# LANGUAGE DeriveGeneric #-} import GHC.Generics import Data.Text import Data.Aeson import Data.ByteString.Lazy First let us create a data type Person: data Person = Person { firstName :...
You should not save props into state. It is considered an anti-pattern. For example: export default class MyComponent extends React.Component { constructor() { super(); this.state = { url: '' } this.onChange = this.onChange.bind(this); ...

Page 380 of 826