Skip to content

Instantly share code, notes, and snippets.

View colwem's full-sized avatar

Martin Colwell colwem

View GitHub Profile
eq
[ { total_runtime: 368,
total_step_runtime: 25,
average_step_runtime: 0.00025 },
{ total_runtime: 477,
total_step_runtime: 57,
average_step_runtime: 0.00057,
total_off_baseline: 106,
total_step_off_baseline: 25,
average_step_off_baseline: 0.00024999999999999995 } ]
create: function(context, newUser) {
// Initialize all the fields.
const d = new Date().getTime();
const userToClient = _.assign({
createdTime: d
}, defaults, newUser);
// Verify that the current user is an admin
isAdminPromise = userService.currentUser(context).then((currentUser) => {
if (get(environment, 'config.clients.user.adminToCreate', true)) {
#!/usr/bin/env node
'use strict';
var promise = {
state: 'pending',
value: null,
dependencies: [],
myApi.getProductionData = function(case_id) {
return new Promise(function(resolve, reject){
myApi.getToken().then(function(response) {
var data_json = '';
sagent
.get(myApi.url + '/v1/cases/' + case_id + '/productionSets/')
.set('Content-Type', 'application/json')
.set('Content-Length', data_json.length)
.set('my-auth-token', response)

We have two events A and B. By event I mean it in the temporal sense. They each have a start time and a duration.
A and B cannot occur at the same time. Meaning:

A.starttime + A.duration < B.starttime or B.starttime + B.duration < A.starttime

Now all we know is what the the pdf would be for A.starttime, A.duration, B.starttime, B.duration if the confict constraint didn't exist. But since that constraint does exist how do we find the new pdfs? How do I extend this to n events?

'use strict';
var Promise = require('bluebird');
var foo = function() {
return new Promise(function(resolve, reject) {
setTimeout(function() {
reject();
}, 1000);
});
};
'use strict';
let Promise = require('bluebird');
Promise.try(() => {
test();
})
function test() {
throw new Error('message');
it('returns errors for both username and password when submitting empty user object', function (done) {
var user = User.forge({});
var errors;
user.register()
.then((function (res) {
console.log('supposed to be rejected', res);
}))
.catch(function (err) {
errors = err;
@colwem
colwem / until.js
Created April 20, 2016 02:29
function execute until promise condition fails
function until(fn, condition) {
condition()
.then((met) => {
if(met) {
fn().then(() => {
until(fn, condition);
});
}
});
}
@colwem
colwem / test-rx.js
Last active April 22, 2016 20:44
using rx.js queries with promises
let value = 20;
Rx.Observable.defer(() => {
return Rx.Observable.fromPromise(Promise.try(() => {
console.log('test/rx.js: 16');
console.log(value);
return value -= 1;
}));
})