Skip to content

Instantly share code, notes, and snippets.

View BrianSigafoos's full-sized avatar

Brian Sigafoos BrianSigafoos

View GitHub Profile
@BrianSigafoos
BrianSigafoos / aws_iam_secret_to_smtp_password.md
Created October 29, 2022 23:31 — forked from damusix/aws_iam_secret_to_smtp_password.md
Convert AWS IAM credentials to AWS SMTP credentials

Convert AWS IAM credentials to AWS SMTP credentials

If you do, or want to, use AWS to deploy your apps, you will end up using AWS SES via SMTP when you're launching an app that sends out emails of any kind (user registrations, email notifications, etc). For example, I have used this configuration on various Ruby on Rails apps, however, it is just basic SMTP configurations and crosses over to any framework that supports SMTP sendmail.

There are two ways to go about this:

Luckily, you found this MD file and the NOT SO EASY WAY is suddenly copy-pasta... sudo yum....

@BrianSigafoos
BrianSigafoos / mac_m1_development.md
Last active January 4, 2022 20:36
Apple Mac M1 development tips and hacks

Development

Open terminal as X86, then run webpack:

arch -x86_64 zsh
yarn install && yarn webpack

Setup

@BrianSigafoos
BrianSigafoos / 0_k8s_security_checklist.md
Last active August 27, 2021 13:36
Kubernetes Security checklist

Kubernetes Security

NSA/CISA Kubernetes Hardening Guidance

A summary of the key recommendations from each section are:

  • Kubernetes Pod security
    • Use containers built to run applications as non-root users
    • Where possible, run containers with immutable file systems
  • Scan container images for possible vulnerabilities or misconfigurations
@BrianSigafoos
BrianSigafoos / mock_env.rb
Created August 23, 2021 11:46 — forked from jazzytomato/mock_env.rb
Simple method to mock environment variable in ruby with minitest or other testing framework
# in test_helper.rb (for example)
def mock_env(partial_env_hash)
old_env = ENV.to_hash
ENV.update partial_env_hash
begin
yield
ensure
ENV.replace old_env
end
end
@BrianSigafoos
BrianSigafoos / kubernetes_oh_my_zsh_aliases.md
Last active August 27, 2021 13:51
Kubernetes Oh My Zsh aliases

Kubernetes Oh My Zsh aliases

# This command is used a LOT both below and in daily life
alias k=kubectl

# Execute a kubectl command against all namespaces
alias kca='_kca(){ kubectl "$@" --all-namespaces;  unset -f _kca; }; _kca'

# Apply a YML file
@BrianSigafoos
BrianSigafoos / application_component.rb
Created December 21, 2020 15:38
Fetch or fallback for Rails ViewComponent
# frozen_string_literal: true
class ApplicationComponent < ViewComponent::Base
private
# Reference: https://www.youtube.com/watch?v=YVYRus_2KZM&t=302s
def fetch_or_fallback(allowed_values, given_value, fallback)
if allowed_values.include?(given_value)
given_value
else
[
{
"key": "cmd+q",
"command": "-workbench.action.quit",
},
{
"key": "alt+cmd+.",
"command": "workbench.action.terminal.focusAtIndex1"
},
{
@BrianSigafoos
BrianSigafoos / README.md
Last active February 23, 2023 19:58
Rails module to manage Stripe subscriptions from Stripe Checkout

Stripe CLI

  • Install the Stripe CLI with: brew install stripe/stripe-cli/stripe
  • Login to our Stripe account: stripe login
  • Listen for Stripe webhooks using Latest API version and forward to:
    • yarn stripe:listen, which does:
    • stripe listen --latest --forward-to http://localhost:3000/webhook_events/stripe
  • Replay events locally with stripe trigger <event type>:
  • stripe trigger checkout.session.completed
@BrianSigafoos
BrianSigafoos / change_all_tables.sql
Created February 13, 2020 20:55
Postgresql snippets
SELECT tablename FROM pg_tables WHERE schemaname = 'public';
-- Move out of public
DO
$$
DECLARE
row record;
BEGIN
FOR row IN SELECT tablename FROM pg_tables WHERE schemaname = 'public' -- and other conditions, if needed
LOOP
EXECUTE 'ALTER TABLE public.' || quote_ident(row.tablename) || ' SET SCHEMA valimail_defend_stage_reporting_20181127_super;';
@BrianSigafoos
BrianSigafoos / unused_indexes.sql
Last active August 21, 2020 12:09
Find unused indexes that can be pruned. Reference: https://wiki.postgresql.org/wiki/Index_Maintenance
SELECT
t.schemaname,
t.tablename,
indexname,
c.reltuples AS num_rows,
pg_size_pretty(pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(t.tablename)::text)) AS table_size,
pg_size_pretty(pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(indexrelname)::text)) AS index_size,
pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(t.tablename)::text) AS table_size_raw,
pg_relation_size(quote_ident(t.schemaname)::text || '.' || quote_ident(indexrelname)::text) AS index_size_raw,
CASE WHEN indisunique THEN 'Y'