Skip to content

Instantly share code, notes, and snippets.

View colwem's full-sized avatar

Martin Colwell colwem

View GitHub Profile
/var/folders/9d/d6bmpjk13zs7jp1r2mhl20d80000gn/T/python-build.20190113193535.9980 ~/workshop/lichess4545-teams
01/13 19:35:38 [NOTICE] Allocating disk space. Use --file-allocation=none to disable it. See --file-allocation option in man page for more details.
01/13 19:35:38 [NOTICE] Download complete: /private/var/folders/9d/d6bmpjk13zs7jp1r2mhl20d80000gn/T/python-build.20190113193535.9980/Python-3.6.8.tar.xz
Download Results:
gid |stat|avg speed |path/URI
======+====+===========+=======================================================
4e5dc8|OK | 28MiB/s|/private/var/folders/9d/d6bmpjk13zs7jp1r2mhl20d80000gn/T/python-build.20190113193535.9980/Python-3.6.8.tar.xz
@colwem
colwem / promise-nesting.js
Last active June 23, 2016 19:17
Promise nesting
Promise = require('bluebird');
promiseOfA.then((a) => {
return usesAPromisesB(a).then((b) => {
return usesAAndB(a, b);
});
});
// or
@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;
}));
})
@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);
});
}
});
}
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;
'use strict';
let Promise = require('bluebird');
Promise.try(() => {
test();
})
function test() {
throw new Error('message');
'use strict';
var Promise = require('bluebird');
var foo = function() {
return new Promise(function(resolve, reject) {
setTimeout(function() {
reject();
}, 1000);
});
};

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?

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)
#!/usr/bin/env node
'use strict';
var promise = {
state: 'pending',
value: null,
dependencies: [],