Following code will release the lock. There will be no problem. Behind the scenes lock statement works as try finally
lock(locker)
{
throw new Exception();
}
More can be seen in the C# 5.0 Specification:
A lock statement of the form
lock (x) ...
where x is an expression of a referenc...
Partial application means calling a function with less arguments than it has and saving the result as another function (that waits for the rest of the arguments).
multiplyBy: Int -> Int -> Int
multiplyBy x y =
x * y
multiplyByTwo : Int -> Int -- one Int has disappeared! we ...
Enum classes as any other classes can have a constructor and be initialized
enum class Color(val rgb: Int) {
RED(0xFF0000),
GREEN(0x00FF00),
BLUE(0x0000FF)
}
Enum classes can also declare members (i.e. properties and functions). A semicolon (;) must be placed between the last enum object and the first member declaration.
If a member is abstract, the enum objects must implement it.
enum class Color {
RED {
override val rgb: Int = 0xFF0000
...
The routing configuration is included in your app/config/config.yml file, by default the app/config/routing.yml file.
From there you can link to the controllers that have annotated routing configuration:
# app/config/routing.yml
app:
resource: "@AppBundle/Controller"
type: ...
The size of a canvas is the area it occupies on the page and is defined by the CSS width and height properties.
canvas {
width : 1000px;
height : 1000px;
}
The canvas resolution defines the number of pixels it contains. The resolution is set by setting the canvas element width and heigh...
This example will show you how to create a simple animation using the canvas and the 2D context. It is assumed you know how to create and add a canvas to the DOM and obtain the context
// this example assumes ctx and canvas have been created
const textToDisplay = "This is an example that uses...
Pyinstaller is a normal python package. It can be installed using pip:
pip install pyinstaller
Installation in Windows
For Windows, pywin32 or pypiwin32 is a prerequisite. The latter is installed automatically when pyinstaller is installed using pip.
Installation in Mac OS X
PyInstaller works...
Think about a situation where we need to callback a function with arguments.
std::function used with std::bind gives a very powerful design construct as shown below.
class A
{
public:
std::function<void(int, const std::string&)> m_CbFunc = nullptr;
void foo()
{
...
Assumptions for this example:
You have a class, foo.bar.Baz.
You'd like to create a run configuration that runs the main method.
It's in a module called fooBar.
In your gradle file:
idea {
workspace.iws.withXml { provider ->
// I'm not actually sure why this is necessar...
insert :: Ord a => a -> [a] -> [a]
insert x [] = [x]
insert x (y:ys) | x < y = x:y:ys
| otherwise = y:(insert x ys)
isort :: Ord a => [a] -> [a]
isort [] = []
isort (x:xs) = insert x (isort xs)
Example use:
> isort [5,4,3,2,1]
Result:
[1,2,3,4...
Bash indirection permits to get the value of a variable whose name is contained in another variable. Variables example:
$ red="the color red"
$ green="the color green"
$ color=red
$ echo "${!color}"
the color red
$ color=green
$ echo "${!color}"
the ...
${parameter:-word}
If parameter is unset or null, the expansion of word is substituted.
Otherwise, the value of parameter is substituted.
$ unset var
$ echo "${var:-XX}" # Parameter is unset -> expansion XX occurs
XX
$ var="" # Parameter is null ...
The modules of a multi-module project are aggregated from a hierarchical structure.
The root pom packing should look like:
<packaging>pom</packaging>
The following will be the directory structure of the project:
|-- sample-app
\ `-- pom.xml
|-- sample-module-1
| `--...
Creates a image representing a linear gradient of colors.
linear-gradient( 0deg, red, yellow 50%, blue);
This creates a gradient going from bottom to top, with colors starting at red, then yellow at 50%, and finishing in blue.
An operator can be used to manipulate the flow of objects from Observable to Subscriber.
Observable<Integer> integerObservable = Observable.just(1, 2, 3); // creating a simple Integer observable
Subscriber<String> mSubscriber = new Subscriber<String>() {
@Override
publi...
import pandas as pd
df = pd.DataFrame(np.random.randn(5, 5), columns=list('ABCDE'))
To generate various summary statistics. For numeric values the number of non-NA/null values (count), the mean (mean), the standard deviation std and values known as the five-number summary :
min: minimum (smal...