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
const { S3, GetObjectCommand } = require("@aws-sdk/client-s3");
const S3C = new S3(S3Config.mms());
response = await S3C.send(new GetObjectCommand(params));
data = await this.streamToString(response.Body);
async streamToString(stream) {
return new Promise((resolve, reject) => {
const chunks = [];
stream.on("data", (chunk) => chunks.push(chunk));
@metaskills
metaskills / production.rb
Created May 31, 2021 14:09
Using Rack Deflater in Lambda with Rails
# In config/environments/production.rb
config.middleware.insert_after ActionDispatch::Static, Rack::Deflater, sync: false
@metaskills
metaskills / deploy.yml
Created March 20, 2021 17:27
Private GitHub ECR Action Abstract
- name: Checkout (private actions)
uses: daspn/private-actions-checkout@v2
with:
actions_list: '["myorg/create-ecr-repo@main"]'
ssh_private_key: ${{ secrets.MYORG_GITHUB_SSH_KEY }}
- name: ECR
uses: ./.github/actions/create-ecr-repo
with:
stage: ${{ github.event.inputs.stage }}
repo-name: myorg/myapp
@metaskills
metaskills / proposal.md
Created March 9, 2021 10:30
Modernizing Rails with Serverless Containers - RailsConf 2021 Proposal

Abstract

Rails was made for servers. From web servers to background jobs, orchestrating the complexity of Rails in our cloud's infrastructure is hard work. We can not Kubernetes our way out of it either. There is a better way...one that is not well understood. With AWS Lambda and event-driven methodologies, we can fundamentally reinvent our beloved framework. It can change, and indeed thrive, without servers.

For Review Committee

Details

AWS Lambda is a commoditized compute platform of the future. Deeply integrated within AWS, it allows your Rails architecture to be completely reimagined atop fully managed infrastructure resources like API Gateway, SQS, S3, CloudWatch, VPC NAT Gateways, IAM, and so much more. As we explore Rails on Lambda, a pattern of evaporating concerns will become a common theme.

@metaskills
metaskills / Arel.md
Created December 19, 2013 18:45
My 3 Items For Today's Lunch & Learn With Arel

Before We Beging

This is ActiveRecord's Relation::QueryMethods implementation where most SQL is built.

  • Will talk about:
    • collapse_wheres
    • reverse_order_value
@metaskills
metaskills / template.yml
Last active January 15, 2021 19:47
Lambdakiq Lamby Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: LambdakiqRail
Parameters:
RailsEnv:
Type: String
Default: staging
AllowedValues:
@metaskills
metaskills / omniauth.rb
Created November 20, 2020 22:23
AWS SSO Omniauth
metadata = Rails.root.join 'config', 'myapp_ins-8d2c1e14da9ca2bc.xml'
idpdata = File.read(metadata)
parser = OneLogin::RubySaml::IdpMetadataParser.new
SAML_SETTINGS = parser.parse_to_hash(idpdata)
Rails.application.config.middleware.use OmniAuth::Builder do
provider :saml, SAML_SETTINGS.merge(
issuer: 'myapp'
)
end
# 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 / gist:6414713
Created September 2, 2013 16:30
Jekyll tasks/post to help create a new post.
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: provide a title argument."
exit -1
else
title="$@"
fi
d=$(date +"%Y-%m-%d")
@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