Skip to content

Instantly share code, notes, and snippets.

View danillouz's full-sized avatar

Daniël Illouz danillouz

View GitHub Profile
@danillouz
danillouz / call-stack.js
Last active September 14, 2018 08:57
Simple routine to illustrate the call stack.
'use strict';
function work() {
console.log('do work');
}
function main() {
console.log('main start');
work();
@danillouz
danillouz / timeout.js
Created September 10, 2018 20:47
Timeout routine.
'use strict';
function timeout(ms) {
console.log('timeout start');
return new Promise(resolve => {
setTimeout(() => {
console.log(`timeout cb fired after ${ms} ms`);
resolve();
@danillouz
danillouz / timeout-diff.md
Created September 10, 2018 18:13
Timeout routine as Lambda handler await diff.
- timeout(5e3);
+ await timeout(5e3);
@danillouz
danillouz / lambda.js
Created September 10, 2018 18:10
Timeout routine as Lambda handler.
'use strict';
function timeout(ms) {
console.log('timeout start');
return new Promise(resolve => {
setTimeout(() => {
console.log(`timeout cb fired after ${ms} ms`);
resolve();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
#container {
background: #ddd;
transition: transform 0.5s;
@danillouz
danillouz / mocha-generators.js
Last active July 9, 2022 10:51
Use generator functions in mocha js test suite methods.
/**
* Make sure the following is included in `/test/index.js`
*
* ```javascript
* 'use strict';
*
* const mocha = require('mocha');
* const coMocha = require('co-mocha');
*
* coMocha(mocha);
@danillouz
danillouz / destructure-nested-object.js
Created May 3, 2016 21:30
Check yourself before you destructure yourself.
const data = {
entry: [
{
messaging: [
{
senderId: 1,
payload: {
text: 'hello'
}
}