Skip to content

Instantly share code, notes, and snippets.

@mike-hogan
mike-hogan / index.js
Created October 26, 2015 15:34
Get a promise work on Node 0.10.36 on AWS Lamdba
"use strict";
var Promise = require("es6-promise").Promise;
exports.learn = function (event, context) {
var promise = function (number) {
return new Promise(function (resolve, reject) {
var f = function(){resolve(number)};
setTimeout(f, 5000);
@mike-hogan
mike-hogan / DynamoDbWriter.js
Last active July 17, 2019 19:53
Nodejs DynamoDB writer with exponential back off
"use strict";
var fs = require('fs');
var path = require('path');
var AWS = require('aws-sdk');
var util = require('util');
var stream = require('readable-stream');
var _ = require('lodash');
@mike-hogan
mike-hogan / index.html
Created July 22, 2016 09:00
Editor for spreadshirt shirt, with printing area calculated and shown
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
@mike-hogan
mike-hogan / GivenWhenThenYatspec.java
Created February 24, 2017 11:16
How to get given,when,then with interesting givens and inputs and outputs with Yatspec
package learning.yatspec;
import com.googlecode.yatspec.junit.SpecRunner;
import com.googlecode.yatspec.state.givenwhenthen.*;
import org.eclipse.jetty.http.HttpStatus;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.eclipse.jetty.http.HttpStatus.Code.OK;
import {head, tail} from "../../src/lodash/lodash";
function extractTermsRecursive(collector: string[], accumulatingTerm: string, depth: number, currentCharacter: string | null, remainingCharacters: string[], openingDelimiter: string, closingDelimiter: any):string[] {
if(currentCharacter === null) {
return collector
}
if(currentCharacter === openingDelimiter) {
return extractTermsRecursive(collector, accumulatingTerm + currentCharacter, depth + 1, head(remainingCharacters), tail(remainingCharacters), openingDelimiter, closingDelimiter)
}
if(currentCharacter === closingDelimiter) {
@mike-hogan
mike-hogan / deploy.ts
Last active March 11, 2021 14:53
Prep a rushjs project for deployment in Firebase Functions
/**
* This script will makes a rushjs project ready for deployment in Firebase Cloud Functions.
*
* It creates a staging directory with rewritten package.json files, and all local rushjs dependencies copied.
*
* It requires ./firebase-files to contain:
* .firebaserc
* .firebase.json
* functions/tsconfig.json
*