Instantly share code, notes, and snippets.

View sam-translate.py
#!/usr/bin/env python2
"""Convert SAM templates to CloudFormation templates.
Known limitations: cannot transform CodeUri pointing at local directory.
Usage:
sam-translate.py --input-file=sam-template.yaml [--output-file=<o>]
Options:
View aws-cloudformation-resource-name-limit.md

Using custom resource names in CloudFormation can potentially cause resources' physical ids to exceed the allowed limit of 64 characters. Especially with nested stacks, as AWS::CloudFormation::Stack does not support custom names causing nested stacks to always be named automatically in the format <logical-id>-XXXXXXXXXXXX, with XXXXXXXXXXXX being a autogenerated identifier.

Below is an example of AWS::Lambda::Function within a nested CloudFormation stack.

With functionName

Physical resource id is generated using the following format.

<root-stack-name>-XXXXXXXXXXXX-<lambda-function-name>

Quickly exceeds max length 64 characters.

View aws-template-bucket-custom-acl.yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Parameters:
BucketPrefix:
Type: String
Description: "The prefix used for all S3 buckets."
AllowedPattern: "[a-z-]+"
Resources:
View gcp-template-bucket-custom.jinji
resources:
# Bucket to hold all asset
- name: {{ properties['bucket-prefix'] }}-assets
type: storage.v1.bucket
accessControl:
gcpIamPolicy:
bindings:
- role: roles/storage.objectAdmin
members:
View dedup_pipeline.go
package main
import (
"fmt"
"math/rand"
"time"
)
func generate(nums ...int) chan int {
out := make(chan int)
View keybase.md

Keybase proof

I hereby claim:

  • I am christianklotz on github.
  • I am christianklotz (https://keybase.io/christianklotz) on keybase.
  • I have a public key whose fingerprint is C379 1DED 2328 2727 E094 4D67 E8B9 609E 233F D8AC

To claim this, I am signing this object:

View circle.yml
general:
artifacts:
- "coverage/lcov-report"
machine:
node:
version: 7.6.0
# environment:
# set the following variables in CircleCI project settings
# AWS_ACCESS_KEY_ID
# AWS_SECRET_ACCESS_KEY
View package-ortools-app.sh
#!/bin/bash
DEST_DIR=$(dirname $(realpath -s $0));
echo "Copy all native libraries...";
mkdir -p ./lib && find $directory -type f -name "*.so" | xargs cp -t ./lib;
echo "Create package...";
zip -r dist.zip your-python-script.py lib;
rm -r ./lib;
View install-ortools.sh
#!/bin/bash
echo "Dowloading Google's Operations Research tools...";
ORTOOLS_TAR=or-tools.python.examples_v4.4.3842.tar.gz;
ORTOOLS_TAR_URL=https://github.com/google/or-tools/releases/download/v4.4/${ORTOOLS_TAR};
curl -O -L ${ORTOOLS_TAR_URL};
tar -xzf ${ORTOOLS_TAR}; cd ortools_examples; python setup.py install;
View food-request-validation-failed.json
{
"message": "validation failed",
"code": 1234,
"errors": [{
"code": 5678,
"message": "not so healthy",
"field": "food",
"suggested_value": "🍎"
}]
}