Skip to content

Instantly share code, notes, and snippets.

@cmawhorter
cmawhorter / test-smtp.js
Created May 11, 2018 16:01
Quick nodejs script to send a test smtp message using nodemailer
'use strict';
// Before running, you need to yarn add yargs nodemailer
// And also replace this with your email:
const DEFAULT_TO_EMAIL = '';
// Username password correct? Make sure your smtp provider doesn't
// have a from/to email address whitelist, or if it does, both emails
// are on it.
@cmawhorter
cmawhorter / mp-util-classes.css
Created October 25, 2017 19:03
Margin and padding utility classes
.ma-0,
.my-0,
.mt-0 {
margin-top: 0;
}
.ma-q,
.my-q,
.mt-q {
margin-top: .25rem;
@cmawhorter
cmawhorter / mithril-table-example.html
Created March 3, 2017 19:19
concept of loading mithril components and passing around data structures
<body>
<script>
// our data returned from server
var myMockEventObject = {
id: 'trkevt_1',
created: '',
updataed: '',
};
// pretend data returned from server
@cmawhorter
cmawhorter / index.js
Created February 13, 2017 19:36
lambda hello world
module.exports.handle = function(event, context, callback) {
callback(null, 'hello world!');
};
@cmawhorter
cmawhorter / blah.js
Created January 24, 2017 19:52
rollup lazy top scope for node deps thoughts
let nodeDeps = {};
let nodeCache = {};
// some dependency
Object.defineProperty(nodeDeps, 'some_module', {
get: () => {
if (process.argv[2] !== 'hello') throw new Error('hello must be first argument');
const nodeModule = nodeCache.some_module || { world: () => console.log('world') };
return nodeModule;
}
@cmawhorter
cmawhorter / list-of-example-arns.js
Created January 21, 2017 02:13
list of all the example arns from the aws arns and namespaces doc page
// all the example arns from this page: http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
var arns = [
'arn:aws:elasticbeanstalk:us-east-1:123456789012:environment/My App/MyEnvironment',
'arn:aws:iam::123456789012:user/David',
'arn:aws:rds:eu-west-1:123456789012:db:mysql-db',
'arn:aws:s3:::my_corporate_bucket/exampleobject.png',
'arn:aws:artifact:::report-package/Certifications and Attestations/SOC/*',
'arn:aws:artifact:::report-package/Certifications and Attestations/ISO/*',
'arn:aws:artifact:::report-package/Certifications and Attestations/PCI/*',
'arn:aws:autoscaling:us-east-1:123456789012:scalingPolicy:c7a27f55-d35e-4153-b044-8ca9155fc467:autoScalingGroupName/my-test-asg1:policyName/my-scaleout-policy',
@cmawhorter
cmawhorter / build.js
Created January 20, 2017 02:19
rollup and babel cwd
'use strict';
const path = require('path');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const builtins = require('rollup-plugin-node-builtins');
const globals = require('rollup-plugin-node-globals');
'use strict';
var assert = require('assert');
var AWS = require('aws-sdk');
var dynogels = require('dynogels');
var Enjoi = require('enjoi');
var config = {
endpoint: 'http://localhost:8000',
};
@cmawhorter
cmawhorter / mithril-delayed-route-set.js
Created November 28, 2016 00:21
delayed m.route.set for mithril v1 to avoid redirect loops freezing or crashing the browser
if (ENV === 'development') {
var m_route_set = m.route.set;
var lastCall = new Date().getTime();
var minDelayBetweenCalls = 100;
m.route.set = function() {
var args = arguments;
var now = new Date().getTime();
var elapsed = now - lastCall;
lastCall = now;
setTimeout(function() {
@cmawhorter
cmawhorter / mithril-v1-server-render.js
Created November 26, 2016 23:32
mithril v1 on the server. created for dev/testing and prod.
'use strict';
var MockBrowser = require('mock-browser').mocks.MockBrowser;
var jsdom = require('jsdom');
function propagateToGlobal (window) {
for (var key in window) {
if (!window.hasOwnProperty(key)) continue
if (global[key]) {