class MyDelegate {
operator fun getValue(owner: Any?, property: KProperty<*>): String {
return "Delegated value"
}
}
val foo : String by MyDelegate()
println(foo)
The example prints Delegated value
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.
<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...
The window resize events can fire in response to the movement of the user's input device. When you resize a canvas it is automatically cleared and you are forced to re-render the content. For animations you do this every frame via the main loop function called by requestAnimationFrame which does its...
npm init
This will initialize a new NPM project for you - just press enter until it stops asking you questions.
Now you'll notice that you have a new file called package.json. This file will, among other things, keep track of which packages or modules you've installed in your project.
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)
posts = db.relationship('Post', backref='user')
class Post(db.Model):
id = db.Column(db.Integer,...
Locate and open your TIBCO BW bwengine.tra file typlically under TIBCO_HOME/bw/5.12/bin/bwengine.tra (Linux environment)
Look for the line that states:
*** Common variables. Modify these only. ***
Add the following line right after that section
tibco.deployment=%tibco.deployment%
...
A minimal setup for camera output preview (Swift 2, Swift 3)
import UIKit
import AVFoundation
class ViewController: UIViewController {
var session: AVCaptureSession?
var cameraPreviewLayer: AVCaptureVideoPreviewLayer?
override func viewDidLoad() {
super.viewDidLoad()
...
One can use the following methods in order to import a Mercurial Repo into Git:
Using fast export:
cd
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
~/fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
git checkout HEAD
Using Hg-Git:
A very deta...