import "reflect"
// this is effectively a pointer dereference
x := 5
ptr := reflect.ValueOf(&x)
ptr.Type().Name() // *int
ptr.Type().Kind() // reflect.Ptr
ptr.Interface() // [pointer to x]
ptr.Set(4) // panic
value := ptr.Elem() // this is a deref
value.Type().Name() // int...
The following table shows the keywords for built-in C# types, which are aliases of predefined types in the System namespaces.
C# Type.NET Framework TypeboolSystem.BooleanbyteSystem.BytesbyteSystem.SBytecharSystem.ChardecimalSystem.DecimaldoubleSystem.DoublefloatSystem.SingleintSystem.Int32uintSyste...
Introduction
Classes that implement this interface no longer support __sleep() and __wakeup(). The method serialize is called whenever an instance needs to be serialized. This does not invoke __destruct() or has any other side effect unless programmed inside the method. When the data is unseriali...
STEP 1: Installation
Before you can use Angular-UI Router you must include AngularJS itself in your project.
For a detailed guide on that see this documentation.
You can download Angular-UI Router either from their GitHub-Page or from NuGet, NPM, Bower respectively.
After you have included the J...
Select Case can be used when many different conditions are possible. The conditions are checked from top to bottom and only the first case that match will be executed.
Sub TestCase()
Dim MyVar As String
Select Case MyVar 'We Select the Variable MyVar to Work with
Case "...
A dotfile is a file whose names begin with a .. These are normally hidden by ls and not listed unless requested.
For example the following output of ls:
$ ls
bin pki
The -a or --all option will list all files, including dotfiles.
$ ls -a
. .ansible .bash_logout .bashrc .lesshst ...
package {
import flash.display.Sprite;
import flash.events.Event;
public class Viewport extends Sprite {
/** Constructor */
public function Viewport() {
super();
// Listen for added to stage event
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandle...
File level metadata applies to all the code within the file and should be placed at the top of the file:
<?php
/**
* @author John Doe ([email protected])
* @copyright MIT
*/
In order to define a variable inside a linq expression, you can use the let keyword. This is usually done in order to store the results of intermediate sub-queries, for example:
int[] numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
var aboveAverages = from number in numbers
l...
The dexcount plugin counts methods and class resource count after a successful build.
Add the plugin in the app/build.gradle:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral() // or jcenter()
}
dependencies {
classpath 'com.ge...
Html5-Canvas ...
Is an Html5 element.
Is supported in most modern browsers (Internet Explorer 9+).
Is a visible element that is transparent by default
Has a default width of 300px and a default height of 150px.
Requires JavaScript because all content must be programmatically added to the Canv...
The URLVariables class allows you to define data to be sent along with a URLRequest.
Example:
var variables:URLVariables = new URLVariables();
variables.prop = "hello";
variables.anotherProp = 10;
var request:URLRequest = new URLRequest('http://someservice.com');
request.data = v...
First define the circle radius and its center:
var radius:Number = 100;
var center:Point = new Point(35, 70);
Then generate a random angle in radians from the center:
var angle:Number = Math.random() * Math.PI * 2;
Then generate an effective radius of the returned point, so it'll be inside ...
Current file
You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. This is most often used as a logging/debugging technique.
echo "We are in the file:" , __FILE__ , "\n";
Current directory
To get the absolute path to the di...
The first step in optimizing for speed is finding the slowest sections of code. The Timer VBA function returns the number of seconds elapsed since midnight with a precision of 1/256th of a second (3.90625 milliseconds) on Windows based PCs. The VBA functions Now and Time are only accurate to a secon...
A series is a one-dimension data structure. It's a bit like a supercharged array, or a dictionary.
import pandas as pd
s = pd.Series([10, 20, 30])
>>> s
0 10
1 20
2 30
dtype: int64
Every value in a series has an index. By default, the indices are integers, running fro...
Simple example of how to create a custom plugin and DSL for your gradle project.
This sample uses one of the three possible ways of creating plugins.
The three ways are:
inline
buildSrc
standalone plugins
This example shows creating a plugin from the buildSrc folder.
This sample will crea...