Skip to content

Instantly share code, notes, and snippets.

@cuperman
cuperman / .gitconfig
Last active October 24, 2017 22:16
git alias: add no whitespace
[alias]
addnw = !bash -c 'git diff -U0 -w --no-color $@ | git apply --cached --ignore-whitespace --unidiff-zero -'
'use strict';
exports.handler = (event, context, callback) => {
callback(null, {
statusCode: 200,
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
event: event,
@cuperman
cuperman / bind_all_methods.js
Last active November 14, 2017 17:07
Bind methods to this
// Usage:
//
// import bindAllMethods from 'bind_all_methods';
// import React from 'react';
//
// class MyComponent extends bindAllMethods(React.Component) {
// ...
// }
//
export default function bindAllMethods(BaseComponent) {
@cuperman
cuperman / cors_handler.js
Created December 28, 2017 20:10
Supporting CORS using SAM
// cors_handler.js
const ALLOW_HEADERS = [
'Content-Type',
'X-Amz-Date',
'Authorization',
'X-Api-Key',
'X-Amz-Security-Token'
];
@cuperman
cuperman / BaseStack.ts
Created January 30, 2020 04:11
Using Tag Manager
import { StackProps, Stack, Construct, Tag } from '@aws-cdk/core'
export class BaseStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const { tags } = props;
// Make sure everything is tagged
Object.entries(tags).forEach(([name, value]) => {
@cuperman
cuperman / aws_instance_scheduler.md
Last active February 27, 2020 02:40
AWS Instance Scheduler