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...
The web.config system.web.httpRuntime must target 4.5 to ensure the thread will renter the request context before resuming your async method.
<httpRuntime targetFramework="4.5" />
Async and await have undefined behavior on ASP.NET prior to 4.5. Async / await will resume on an arb...
Matplotlib axes are two-dimensional by default. In order to create three-dimensional plots, we need to import the Axes3D class from the mplot3d toolkit, that will enable a new kind of projection for an axes, namely '3d':
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fi...
If you want two or more arguments to be mutually exclusive. You can use the function argparse.ArgumentParser.add_mutually_exclusive_group(). In the example below, either foo or bar can exist but not both at the same time.
import argparse
parser = argparse.ArgumentParser()
group = parser.add_mut...
To modify an existing column in Rails with a migration, run the following command:
rails g migration change_column_in_table
This will create a new migration file in db/migration directory (if it doesn’t exist already), which will contain the file prefixed with timestamp and migration file name w...
Function level annotations help IDEs identify return values or potentially dangerous code
/**
* Adds two numbers together.
*
* @param Int $a First parameter to add
* @param Int $b Second parameter to add
* @return Int
*/
function sum($a, $b)
{
return (int) $a + $b;
}
/**
* ...
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
*/
If a class extends another class and would use the same metadata, providing it @inheritDoc is a simple way for use the same documentation. If multiple classes inherit from a base, only the base would need to be changed for the children to be affected.
abstract class FooBase
{
/**
* @par...
Let's say you need to implement an automatic search box, but the search operation is somewhat costly, like sending a web request or hitting up a database. You may want to limit the amount of search being done.
For example, the user is typing "C# Reactive Extensions" in the search box :
I...
There are two operators for filtering duplicates:
emails.Distinct(); // Never see the same value twice
emails.DistinctUntilChanged(); // Never see the same value twice in a row
You can also pass in a predicate:
emails.DistinctUntilChanged(x => x.Length); // Never see the same length email t...
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...
In order to enable a multidex configuration you need:
to change your Gradle build configuration
to use a MultiDexApplication or enable the MultiDex in your Application class
Gradle configuration
In app/build.gradle add these parts:
android {
compileSdkVersion 24
buildToolsVersion ...
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 ...
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 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...