This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="myForm"> | |
<label for="duration"> Duration: </label><br> | |
<select name="duration" ng-model="selectedDuration" ng-change="durationChange()"> | |
<option ng-repeat="(key, value) in durations" value="{{value}}" selected="{{isSelectedDurationOption(value)}}"> | |
{{key}} | |
</option> | |
</select> | |
</form> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setInterval(() => { | |
new Promise((resolve, reject) => { | |
... | |
resolve(value); | |
... | |
}).then((value) => { ... }); | |
}, 100); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let delay = (ms) => { | |
return new Promise( (resolve, reject) => { | |
setTimeout(() => { resolve(); }, ms); | |
}); | |
}; | |
let digitalRead = (thePin) => { | |
return new Promise((resolve, reject) => { | |
gBoard.digitalRead(thePin, function(value){ | |
resolve(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thisFunctionReturnsAPromise() | |
.then((result) => { | |
console.log("We'll be right back..."); | |
}) | |
.delay(500) | |
.then(() => { | |
console.log("We're back!"); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Promise = require('bluebird') | |
let myDelay = (ms) => { | |
let milliseconds = ms; | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, milliseconds) | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promiseDoWhilst = require('promise-do-whilst'); | |
var Board = require('firmata'); | |
var Promise = require('bluebird'); | |
let gBoard = null; | |
// returns a promised of a connectable port | |
let firmataRequestPort = () => { | |
return Promise.try(() => { | |
return new Promise((resolve, reject) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Promise = require('bluebird'); | |
var promiseDoWhilst = require('promise-do-whilst'); | |
var dgram = require('dgram'); | |
var ANNOUNCEMENT_PORT = 43662; | |
var SUBNET_BROADCAST_ADDRESS = '192.168.1.255'; | |
function sendDatagram(){ | |
let message = new Buffer(JSON.stringify(messageJson)); | |
var client; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dgram = require('dgram'); | |
dgram.createSocket('udp4', (error) => {console.log(`Complete: `, error)}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="menu"> | |
<div class="item" *ngFor="#unt of unitOpts" (click)="changeUnits(unt)"> | |
<div [innerHTML]="unt.formatted" data-tooltip="{{unt.tooltip}}" data-position="right center"></div> | |
</div> | |
</div> | |
produces... | |
browser_adapter.ts:74 EXCEPTION: Error: Uncaught (in promise): Template parse errors: | |
Can't bind to 'tooltip' since it isn't a known native property ("pts" (click)="changeUnits(unt)"> | |
<div [innerHTML]="unt.formatted" [ERROR ->]data-tooltip="{{unt.tooltip}}" data-position="right center"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class Key, class T> | |
QString mapToString(QMap<Key, T> &map){ | |
// this is derivative of the code that qDebug uses to serialize a QVariantMap | |
// qtbase/src/corelib/io/qdebug.h | |
// template <class Key, class T> | |
// inline QDebug operator<<(QDebug debug, const QMap<Key, T> &map) | |
QByteArray buf; | |
QDataStream s(&buf, QIODevice::ReadWrite); | |
s << "("; |