Skip to content

Instantly share code, notes, and snippets.

View rook2pawn's full-sized avatar
💭
Receiving the Love of God in Christ

david wee rook2pawn

💭
Receiving the Love of God in Christ
View GitHub Profile
@rook2pawn
rook2pawn / foo.js
Last active June 25, 2020 01:18
test integration
function testIntegration(executor, timeout) {
let timer;
const timeoutPromise = new Promise((resolve, reject) => {
timer = setTimeout(() => {
console.log("timing out");
screenshot();
reject("timeout");
}, timeout);
});
const testPromise = new Promise((resolve, reject) => {
@rook2pawn
rook2pawn / cordova-android-no-studio.md
Last active February 25, 2019 08:22
Step By Step Cordova - Android Env without Studio
@rook2pawn
rook2pawn / binarysearch-list.js
Created February 20, 2019 20:59
binary search list
const list = [1,1,2,3,5,5,5,5,10,62,95,107,109,202];
function search(list, num) {
// console.log("Searching for :", num, "LIST:", list)
let mid = ~~(list.length / 2);
let item = list[mid];
if (item === num) {
return {isFound:true, num};
}
// Given a stack object of microservices to deploy,
// implement a deploy function that takes this object
// with a provided variable syntax, and runs the
// referenced microservice functions in order
// according to microservice dependencies.
const sleep = async (wait) => new Promise((resolve) => setTimeout(() => resolve(), wait))
const supportedServices = {
database: async (inputs) => {
@rook2pawn
rook2pawn / prebind.md
Created January 26, 2019 02:44
remember to prebind your animation calls if you are going to need bind!

The normal flow is

function animate() {
    requestAnimationFrame(animate);
    // do render stuff
    chicken.position.x++;
}
animate();
var x = function() {
return new Promise ((resolve,reject) => {
console.log("performing x");
setTimeout(() => {
resolve(10)
}, 2000)
})
}
var y = function() {
return new Promise ((resolve,reject) => {
@rook2pawn
rook2pawn / sequentialPromises.js
Created August 14, 2018 11:45
sequential resolution of promises
var x = new Promise ((resolve,reject) => {
setTimeout(() => {
resolve(10)
}, 200)
})
var y = new Promise ((resolve,reject) => {
setTimeout(() => {
resolve(2)
}, 1000)
@rook2pawn
rook2pawn / promiseready.js
Created July 16, 2018 14:32
nanocomponent promise ready
class MyComponent extends Nanocomponent {
constructor(config) {
super();
this.ready = new Promise((resolve, reject) => {
this._resolve = resolve;
})
}
createElement(params) {
// do stuff
}
@rook2pawn
rook2pawn / finished-polyfill.js
Created May 29, 2018 01:10 — forked from simevidas/finished-polyfill.js
Animation.prototype.finished polyfill
// only polyfill .finished in browsers that already support animate()
if (document.body.animate) {
// Chrome does not seem to expose the Animation constructor globally
if (typeof Animation === 'undefined') {
window.Animation = document.body.animate({}).constructor;
}
if (Animation.prototype.finished === undefined) {
Object.defineProperty(Animation.prototype, 'finished', {
// app.js
var html = require('choo/html')
var choo = require('choo')
var app = choo() // 1.
app.route('/', view) // 2.
app.route('/second', second) // 2.
app.mount('body') // 3.