Skip to content

Instantly share code, notes, and snippets.

Avatar
🐙
Being Inkcellent to Each Other

Ken Collins metaskills

🐙
Being Inkcellent to Each Other
View GitHub Profile
@metaskills
metaskills / capysetup.rb
Created Sep 28, 2020
Rails Capybara System Tests Setup
View capysetup.rb
# 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 Jul 25, 2020
Useful for Ruby/Docker SAM Projects
View layer_downloader.rb
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 Jun 16, 2020
Sample API Gateway HTTP API Version 1 Event
View event.json
{
"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
Learning to Program The Cloud
View wizard.sh
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 Apr 25, 2020
Using Jest SAM Local Environment
View jest-environment-samlocal.js
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 Mar 26, 2020
Query Strings Event Values w/Lambda Integration using API Gateway (REST & HTTP API) & Application Load Balancers
View event-data.md

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 Jun 7, 2020
Aurora Serverless IaC Example Using CDK & TypeScript
View aurora-stack.ts
// 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 Dec 28, 2019
ActiveRecord Aurora Serverless - Foreign Key Check Debugging
View gist:3752c66ed2b50599e4b66b7664f1d856
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 Jul 16, 2019
AWS Washington DC Meetup
View talk.md

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

@metaskills
metaskills / log.txt
Created May 15, 2019
customink/ruby-vips-lambda Latest Runtime Build Errors
View log.txt
$ ./bin/build
Sending build context to Docker daemon 130.6kB
Step 1/12 : FROM lambci/lambda:build-ruby2.5
---> b71c0ed10ee3
Step 2/12 : WORKDIR /build
---> Running in 661fe3c895e3
Removing intermediate container 661fe3c895e3
---> 60ba7e7f1d27
Step 3/12 : ARG VIPS_VERSION=8.7.4
---> Running in e29f20323847
You can’t perform that action at this time.