interface Foo {
fun example()
}
class Bar {
fun example() {
println("Hello, world!")
}
}
class Baz(b : Bar) : Foo by b
Baz(Bar()).example()
The example prints Hello, world!
val a = arrayOfNulls<Int>(3) // creates an Array<Int?> of [null, null, null]
The returned array will always have a nullable type. Arrays of non-nullable items can't be created uninitialized.
General-purpose stopwatch for timing how long a function takes to run:
object Benchmark {
fun realtime(body: () -> Unit): Duration {
val start = Instant.now()
try {
body()
} finally {
val end = Instant.now()
return Duration.b...
<View style={[(this.props.isTrue) ? styles.bgcolorBlack : styles.bgColorWhite]}>
If the value of isTrue is true then it will have black background color otherwise white.
If you are unsure which rules to list in your .gitattributes file, or you just want to add generally accepted attributes to your project, you can shoose or generate a .gitattributes file at:
https://gitattributes.io/
https://github.com/alexkaratarakis/gitattributes
<Image style={[this.props.imageStyle]}
source={this.props.imagePath
? this.props.imagePath
: require('../theme/images/resource.png')}
/>
If the path is available in imagePath then it will be assigned to source else the default image path will be assigned.
Installation
pip install Flask-SQLAlchemy
Simple Model
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(80))
email = db.Column(db.String(120), unique=True)
The code example above shows a simple Flask-SQLAlchemy model, we can add an ...
This following example is created by user Michael Dillon from this answer.
Consider the following script:
@set @junk=1 /*
@echo off
cscript //nologo //E:jscript %0 %*
goto :eof
*/
//JScript aka Javascript here
This script snippet does:
Execute the cscript command which calls itsel...
As mentioned here, the old-school method to run another script is by using temporary files. Simple echo it into a file and then run it(and remove it optionally).
Here's the basic concept:
@echo off
echo //A JS Comment > TempJS.js
echo //Add your code>>TempJS.js
cscript //nologo //e...
The rotate(r) method of the 2D context rotates the canvas by the specified amount r of radians around the origin.
HTML
<canvas id="canvas" width=240 height=240 style="background-color:#808080;">
</canvas>
<button type="button" onclick="rotate_c...
You can save a canvas to an image file by using the method canvas.toDataURL(), that returns the data URI for the canvas' image data.
The method can take two optional parameters canvas.toDataURL(type, encoderOptions): type is the image format (if omitted the default is image/png); encoderOptions is ...
My laptop is having Windows 10. Here i am giving steps that you can follow to test and learn Ansible.
SOME THEORY
For Ansible you need a Control Machine and a host(or hosts) to run the Playbook.
Control Machine should be Linux based or MacOS(windows not allowed) and need Python (2.6 or higher v...