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...
While in insert mode, press <C-o> to temporarily leave insert mode and execute a one-off normal command.
Example
<C-o>2w jumps to the second word to the left and returns to insert mode.
Note: Repeating with . will only repeat the actions from returning to insert mode
This allows for ...
C++11 introduced final specifier which forbids method overriding if appeared in method signature:
class Base {
public:
virtual void foo() {
std::cout << "Base::Foo\n";
}
};
class Derived1 : public Base {
public:
// Overriding Base::foo
void foo() f...
A reference is a scalar variable (one prefixed by $ ) which “refers to” some other data.
my $value = "Hello";
my $reference = \$value;
print $value; # => Hello
print $reference; # => SCALAR(0x2683310)
To get the referred-to data, you de-reference it.
say ${$reference}...
Array References are scalars ($) which refer to Arrays.
my @array = ("Hello"); # Creating array, assigning value from a list
my $array_reference = \@array;
These can be created more short-hand as follows:
my $other_array_reference = ["Hello"];
Modifying / Using array ref...
The URLRequest and URLLoader classes work together to make requests from Flash to external resources. The URLRequest defines information about the request e.g. the request body and the request method type, and the URLLoader references this to perform the actual request and provide a means of being n...
Assuming we have an array myArray:
var value:* = myArray[int(Math.random() * myArray.length)];
Note we use int to cast the result of Math.random() to an int because values like 2.4539543 would not be a valid array index.
If you need to roll for a true or false in an "x% chance" situation, use:
function roll(chance:Number):Boolean {
return Math.random() >= chance;
}
Used like:
var success:Boolean = roll(0.5); // True 50% of the time.
var again:Boolean = roll(0.25); // True 25% of the time.
...
Gets System.Type object for a type.
System.Type type = typeof(Point) //System.Drawing.Point
System.Type type = typeof(IDisposable) //System.IDisposable
System.Type type = typeof(Colors) //System.Drawing.Color
System.Type type = typeof(List<>) //System.Collections....
Value Type (where T : struct)
The built-in primitive data types, such as char, int, and float, as well as user-defined types declared with struct, or enum. Their default value is new T() :
default(int) // 0
default(DateTime) // 0001-01-01 12:00:00 AM
default(char) // '...
To get started with Thymeleaf visit official download page.
Maven dependency
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
Gradle dependency
compile gr...
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...
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...
Detailed instructions on getting openerp set up or installed in Debian/Ubuntu.
To install from source code, we need Python 2.7, Git and a PostgreSQL database:
$ sudo apt-get install git python-pip python2.7-dev -y
$ sudo apt-get install postgresql -y
$ sudo su -c "createuser -s $(whoami)&qu...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject.
You can trigger builds at the command line as follows:
mxmlc -source-path="." -default-size [width in...
Imagine the following XML:
<root>
<element>hello</element>
<another>
hello
</another>
<example>Hello, <nested> I am an example </nested>.</example>
</root>
The following XPath expression:
//*[text() = 'hel...