Skip to content

Instantly share code, notes, and snippets.

@cmawhorter
cmawhorter / test-smtp.js
Created May 11, 2018
Quick nodejs script to send a test smtp message using nodemailer
View test-smtp.js
'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 Oct 25, 2017
Margin and padding utility classes
View mp-util-classes.css
.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 Mar 3, 2017
concept of loading mithril components and passing around data structures
View mithril-table-example.html
<body>
<script>
// our data returned from server
var myMockEventObject = {
id: 'trkevt_1',
created: '',
updataed: '',
};
// pretend data returned from server
@cmawhorter
cmawhorter / index.js
Created Feb 13, 2017
lambda hello world
View index.js
module.exports.handle = function(event, context, callback) {
callback(null, 'hello world!');
};
@cmawhorter
cmawhorter / blah.js
Created Jan 24, 2017
rollup lazy top scope for node deps thoughts
View blah.js
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 Jan 21, 2017
list of all the example arns from the aws arns and namespaces doc page
View list-of-example-arns.js
// 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 Jan 20, 2017
rollup and babel cwd
View build.js
'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');
View dynogels-credentials-loading-tests.js
'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 Nov 28, 2016
delayed m.route.set for mithril v1 to avoid redirect loops freezing or crashing the browser
View mithril-delayed-route-set.js
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 Nov 26, 2016
mithril v1 on the server. created for dev/testing and prod.
View mithril-v1-server-render.js
'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]) {