Skip to content

Instantly share code, notes, and snippets.

🏐
Focusing

Operations Research Engineering Software+ ORESoftware

View GitHub Profile
@ORESoftware
ORESoftware / bfs.js
Last active Apr 12, 2019
Simple breadth first traversal example
View bfs.js
'use strict';
const queue = [];
const root = {};
const main = {
name: 'main',
linkedSet:{
a: {
name: 'a',
@ORESoftware
ORESoftware / client.md
Last active Mar 19, 2019
Python swallows an error
View client.md

Run this container (it's a server):

docker run -p 6970:6970 -it oresoftware/live-mutex-broker:latest

then run this python script with Python 3.6.7:

@ORESoftware
ORESoftware / promises.ts
Last active Mar 11, 2019
promise api technique
View promises.ts
export class Worker {
getLock(v: string, cb: Function){
this.getLockInternal(v,cb);
}
getLockp(v:string){
return new Promise((resolve,reject) => {
this.getLockInternal(v, (err,result) => {
View null.9.ts
const passAStringOrNull = (v: StringOrNull) => {
let input: String;
if(v == null){
input = "default string";
}
else {
input = v;
}
return goDoDatabaseStuff(input);
View null.8.ts
const passAStringOrNull = (v: StringOrNull) => {
if(v == null){
v = "default string";
}
return goDoDatabaseStuff((String)v);
}
View null.7.ts
const goDoDatabaseStuff = (v: String) => {
return doWhatever();
}
View null.6.ts
const passAStringOrNull = (v: StringOrNull) => {
return goDoDatabaseStuff(v);
}
View null.5.ts
const getAStringOrNull = (v: Object) : StringOrNull => {
return v === bar ? v.toString() : null;
};
View null.4.ts
var x = getAStringOrNullWithoutSafety();
if(x != null) {
log.info(x.charAt(0));
}
View null.3.ts
log.info(withoutSafety().charAt(0)); // might throw an NPE
You can’t perform that action at this time.