Skip to content

Instantly share code, notes, and snippets.

@adrianhall
adrianhall / AppSync-Example.yaml
Created April 13, 2018 16:01
An example CloudFormation template for AWS AppSync
---
Description: AWSAppSync DynamoDB Example
Resources:
GraphQLApi:
Type: "AWS::AppSync::GraphQLApi"
Properties:
Name: AWSAppSync DynamoDB Example
AuthenticationType: AWS_IAM
PostDynamoDBTableDataSource:
@lfalke
lfalke / StripeCardsSection.js
Last active August 8, 2023 05:10
Usage of react-stripe-elements with Material UI (v1.0) styling
import React, { PureComponent } from 'react'
import Grid from 'material-ui/Grid'
import { CardNumberElement, CardExpiryElement, CardCVCElement } from 'react-stripe-elements'
import StripeElementWrapper from './StripeElementWrapper'
export default class extends PureComponent {
static displayName = 'StripeCardsSection'
@acolyer
acolyer / jessfraz.md
Created November 19, 2017 13:39
Containers, operating systems and other fun things from The Morning Paper
@bradwestfall
bradwestfall / S3-Static-Sites.md
Last active March 13, 2024 15:02
Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects. Also covers deployments.

S3 Static Sites

⚠ This post is fairly old. I don't keep it up to date. Be sure to see comments where some people have posted updates

What this will cover

  • Host a static website at S3
  • Redirect www.website.com to website.com
  • Website can be an SPA (requiring all requests to return index.html)
  • Free AWS SSL certs
  • Deployment with CDN invalidation
@smithclay
smithclay / weird-lambda-binaries-recipe.md
Created July 28, 2017 02:59
Recipe for Getting Strange Binaries Running in AWS Lambda

Recipe for running strange binaries in AWS Lambda

In general, the command ldd and the environment variable LD_LINKER_PATH is your best friend when running new, untested binaries in Lambda. My process (which I want to get around to automating one day, maybe using Packer), goes like this:

  1. Run an EC2 instance with the official AWS Lambda AMI.
  2. Get binary you want to run in AWS Lambda running on the instance (either by installing from a package manager or compiling). 
  3. Run ldd -v ./the-binary. Note all of the shared libraries it requires. You’ll need to remember these.
  4. Copy the binary to your local machine. Upload the binary with your AWS Lambda function code that runs the ldd command inside the handler function using the process execution library from your language of choice. In node, this works just fine: console.log(require('child_process').execSync('ldd -v ./the-binary'))
  5. Note any shared libraries that are missing in the function output. Copy those over from the EC2 instance to a direct
@odigity
odigity / Bluebird.txt
Created May 22, 2017 04:56
A Snapshot of my Bluebird.js Cheat Sheet.
┌──────────┐
──┤ Overview ├─────────────────────────────────────────────────────────────────
└──────────┘
$ npm install --save bluebird
const Promise = require('bluebird')
@fgilio
fgilio / axios-catch-error.js
Last active November 20, 2023 18:25
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@posener
posener / go-kit.md
Last active February 23, 2024 21:35
Why I Recommend to Avoid Using the go-kit Library

Why I Recommend to Avoid Using the go-kit Library

There is a trending 'microservice' library called go-kit. I've been using the go-kit library for a while now. The library provide a lot of convenience integrations that you might need in your service: with service discovery with Consul, distributed tracing with Zipkin, for example, and nice logic utilities such as round robin client side load balancing, and circuit breaking. It is also providing a way to implement communication layer, with support of RPC and REST.

#!/bin/bash
# wrapper around "aws cloudformation" CLI to ignore certain pseudo-errors
# aws cloudformation deploy exits with 255 for "No changes to deploy" see: https://github.com/awslabs/serverless-application-model/issues/71
# this script exits with 0 for that case
STDERR=$(( aws cloudformation "$@" ) 2>&1)
ERROR_CODE=$?
echo ${STDERR} 1>&2
@juhaelee
juhaelee / react-typescript.md
Last active January 26, 2023 00:52
React + Typescript Cheatsheet

React + Typescript Cheatsheet

Setup

If you use atom... download & install the following packages:

What are Typescript type definition files? (*.d.ts)