Skip to content

Instantly share code, notes, and snippets.

View metaskills's full-sized avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
# Setup
aws application-autoscaling \
register-scalable-target \
--service-namespace "lambda" \
--resource-id "function:myapp:live" \
--min-capacity 5 \
--max-capacity 100 \
--scalable-dimension "lambda:function:ProvisionedConcurrency"
@metaskills
metaskills / capysetup.rb
Created September 28, 2020 22:45
Rails Capybara System Tests Setup
# Gemfile
gem 'selenium-webdriver'
# test/application_system_test_case.rb (or capy setup file)
require 'test_helper'
Capybara.server = :webrick
Webdrivers::Chromedriver.required_version = '2.36'
driver_path = Webdrivers::Chromedriver.update
@metaskills
metaskills / layer_downloader.rb
Created July 25, 2020 02:55
Useful for Ruby/Docker SAM Projects
require 'yaml'
require 'open-uri'
require 'aws-sdk-lambda'
class LayerDownloader
def download
File.open(zip_file, 'wb') do |f|
URI.open(location) { |zip| f.write(zip.read) }
end
@metaskills
metaskills / event.json
Created June 16, 2020 13:26
Sample API Gateway HTTP API Version 1 Event
{
"version": "1.0",
"resource": "$default",
"path": "/",
"httpMethod": "GET",
"headers": {
"Content-Length": "0",
"Host": "myawesomelambda.example.com",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15",
"X-Amzn-Trace-Id": "Root=1-5e7fe714-fee6909429159440eb352c40",
@metaskills
metaskills / wizard.sh
Last active May 10, 2020 13:08
Learning to Program The Cloud
insert_file_over_pattern () {
dline=$(sed -n "/${2}/=" $1)
rline=$(expr $dline - 1)
sed --in-place -e "${dline}d" $1
sed --in-place "${rline}r ../inserts/${1}" $1
}
insert_file_over_pattern 'config/application.rb' 'Bundler.require'
@metaskills
metaskills / jest-environment-samlocal.js
Created April 25, 2020 14:29
Using Jest SAM Local Environment
const { spawn } = require('child_process');
const NodeEnvironment = require('jest-environment-node');
const { timeout, TimeoutError } = require('promise-timeout');
class SamlocalEnvironment extends NodeEnvironment {
constructor(config) {
super(config);
}
async setup() {
@metaskills
metaskills / event-data.md
Last active March 26, 2020 16:23
Query Strings Event Values w/Lambda Integration using API Gateway (REST & HTTP API) & Application Load Balancers

This solely tests array query string values since I find these the most interesting edge case. So the query string would be colors[]=blue&colors[]=red for all cases below.

API Gateway HTTP API (version 2.0)

"rawQueryString": "colors[]=blue&colors[]=red",
"queryStringParameters": { "colors[]": "blue,red" }

API Gateway HTTP API (version 1.0)

@metaskills
metaskills / aurora-stack.ts
Last active June 7, 2020 13:36
Aurora Serverless IaC Example Using CDK & TypeScript
// Run `mkdir aurora && cd aurora && cdk init sample-app --language=typescript`
// and replace the `lib/aurora-stack.ts` with this file. May need to remove non-needed
// packages from package.json and add others like "@aws-cdk/aws-rds" and
// "@aws-cdk/aws-secretsmanager"
//
// Running assumes you pass in the following environment variables or hard code values.
//
// * ASCLUSTER_MASTER_USER
// * ASCLUSTER_MASTER_PASS
// * SUBNET_GROUP_NAME
@metaskills
metaskills / gist:3752c66ed2b50599e4b66b7664f1d856
Created December 28, 2019 23:11
ActiveRecord Aurora Serverless - Foreign Key Check Debugging
EXECUTE: SELECT 1 70195508832200
EXECUTE: SELECT @@FOREIGN_KEY_CHECKS 70195508832200
(26.8ms) SELECT @@FOREIGN_KEY_CHECKS
EXECUTE: SET FOREIGN_KEY_CHECKS = 0 70195508832200
(26.3ms) SET FOREIGN_KEY_CHECKS = 0
BEGIN AXicEuEN5ZSHrKMjPizpveE6eyVxSEAFGWl7G4+IL5btSET5zr1f99MtCpfIr0d7nPp3gXTUyMmuo5lVen73a8FDDAZvwQPZL6AQCIs851e1jczSJEOQjPo/ZIAG2tveP2YSzlmhWGPZrmmBRZhjBi5KA8z3wZ1Ma4FJ8KcBtvNtu3nq/TV0cj0= 70195508832200
EXECUTE: DELETE FROM `topics` AXicEuEN5ZSHrKMjPizpveE6eyVxSEAFGWl7G4+IL5btSET5zr1f99MtCpfIr0d7nPp3gXTUyMmuo5lVen73a8FDDAZvwQPZL6AQCIs851e1jczSJEOQjPo/ZIAG2tveP2YSzlmhWGPZrmmBRZhjBi5KA8z3wZ1Ma4FJ8KcBtvNtu3nq/TV0cj0= 70195508832200
Fixtures Load (27.2ms) DELETE FROM `topics`
EXECUTE: DELETE FROM `developers` AXicEuEN5ZSHrKMjPizpveE6eyVxSEAFGWl7G4+IL5btSET5zr1f99MtCpfIr0d7nPp3gXTUyMmuo5lVen73a8FDDAZvwQPZL6AQCIs851e1jczSJEOQjPo/ZIAG2tveP2YSzlmhWGPZrmmBRZhjBi5KA8z3wZ1Ma4FJ8KcBtvNtu3nq/TV0cj0= 70195508832200
Fixtures Load (27.7ms) DELETE FROM `developers`
@metaskills
metaskills / talk.md
Created July 16, 2019 16:33
AWS Washington DC Meetup

Title

Functions to Full-Stack & Back Again

Description

Learn how thinking big with AWS Lambda and moving to Full-Stack Serverless using Web Application Frameworks could help your company's cloud adoption & innovation cycles. This is Custom Ink's story of our lift & shift cloud migration to cloud-native using Lamby (https://lamby.custominktech.com), a Rack/HTTP adapter for API Gateway or Application Load Balancers, as one of our tools to help deliver AWS Well-Architected solutions in a versatile programming environment that uses many languages.

Bio