Skip to content

Instantly share code, notes, and snippets.

View pbzona's full-sized avatar
🤠
having fun on the computer

Phil Z pbzona

🤠
having fun on the computer
View GitHub Profile
@pbzona
pbzona / .tmux.conf
Last active February 23, 2017 19:50
Tmux config file...for now
# Set the default terminal mode to 256color mode
set -g default-terminal "screen-256color"
# enable activity alerts
setw -g monitor-activity on
set -g visual-activity on
# Reset prefix to C-a
unbind C-b
set -g prefix C-a
@pbzona
pbzona / some-script.js
Created September 2, 2017 23:23
Template literal example 1
var name = 'Phil';
console.log(`My name is ${name}`);
@pbzona
pbzona / some-script.js
Last active September 2, 2017 23:32
Template tagging example 2
function templateTag(strings, personName) {
return strings[0] + personName;
}
var name = 'Phil'
var someString = templateTag`My name is ${name}`
console.log(someString);
@pbzona
pbzona / some-script.js
Last active September 4, 2017 23:40
Template tag example 3
function someTemplate(strings, personName, favoriteFood) {
var output = strings[0] + personName + strings[1] + favoriteFood;
if (favoriteFood.toLowerCase() === 'pizza') {
return output + '. HELL YEAH!!!';
} else if (favoriteFood.toLowerCase() === 'broccoli') {
return output + '. GROSS!';
} else {
return output + strings[2];
}
@pbzona
pbzona / ContactFormLambda.js
Last active October 3, 2017 18:01
Boilerplate code for serverless contact form
'use strict';
console.log('Loading function');
const AWS = require('aws-sdk');
const sesClient = new AWS.SES();
/**
* Lambda to process HTTP POST for contact form with the following body
* {
"Email": <contact-email>,
"Subject": <contact-subject>,
"Message": <contact-message>
@pbzona
pbzona / Example Policy Document
Created October 2, 2017 21:38
Policy document example for serverless contact form
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1505675625000",
"Effect": "Allow",
"Action": [
"ses:SendEmail"
],
"Resource": [
@pbzona
pbzona / ContactFormLambda.js
Created October 2, 2017 21:41
Full code for serverless contact form
'use strict';
console.log('Loading function');
const AWS = require('aws-sdk');
const sesClient = new AWS.SES();
const sesConfirmedAddress = "<your-verified-ses-email>";
/**
* Lambda to process HTTP POST for contact form with the following body
* {
"email": <contact-email>,
@pbzona
pbzona / ContactFormLambda.js
Created October 2, 2017 21:44
Constant declarations for serverless contact form
const AWS = require('aws-sdk');
const sesClient = new AWS.SES();
const sesConfirmedAddress = "<your-verified-ses-email>";
@pbzona
pbzona / ContactFormLambda.js
Created October 2, 2017 21:46
Function declaration of getEmailMessage in serverless contact form
function getEmailMessage (emailObj) {
var emailRequestParams = {
Destination: {
ToAddresses: [ sesConfirmedAddress ]
},
Message: {
Body: {
Text: {
Data: emailObj.message
}
@pbzona
pbzona / ContactFormLambda.js
Created October 2, 2017 21:52
Event handler for serverless contact form
exports.handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
var emailObj = JSON.parse(event.body);
var params = getEmailMessage(emailObj);
var sendEmailPromise = sesClient.sendEmail(params).promise();
var response = {
statusCode: 200
};