Skip to content

Instantly share code, notes, and snippets.

@mowings
mowings / mermaid-pdf.md
Created May 3, 2024 14:12
Markup with embedded Mermaid to PDF on OSX

Install pandoc, basic-tex and mermaid-filter

# brew install pandoc
# brew install --cask basictex
# npm i -g mermaid-filter

# Be sure to run the path_helper in an existing shell. Otherwise pdf-latex won't be found
# eval "$(/usr/libexec/path_helper)"

Convert an markdown to pdf

@mowings
mowings / readme.md
Last active February 27, 2024 20:05
Run a shell in an ecs container via SSM
@mowings
mowings / diagrams.md
Last active August 30, 2023 16:00
Diagrams as code
@mowings
mowings / cert.md
Last active June 22, 2023 21:12
Manually request a Let's Encrypt Cert

Sometimes you may need to manually request a certificate from Let's Encrypt. The easiest wat to do this is to run certbot manually from the most current Docker image:

docker run -v `pwd`/cert:/etc/letsencrypt/archive -it certbot/certbot certonly --preferred-challenges dns --manual

Answer the prompts. You will be asked to create TWO acme challenge TXT records named _acme-challenge.fubar.com (where fubar.com is your domain name).

Note that if you use AWS route53 for DNS management, you will add two lines, one for each TXT value, in the dialog data field for the _acme-challenge dns record create, instead of creating two TXT records with the same name (this is just how the route53 UI works).

@mowings
mowings / former2.md
Created March 25, 2023 14:58
Former2 -- Build AWS IaC from existing resources

This applications runs entirely local in your browser and can be used to convert any AWS resource into IaC (CloudFront, Terraform, CDK, Puumi, etc):

Convert AWS Resources to IaC via API

@mowings
mowings / tensorflow.nim
Created February 26, 2023 17:45 — forked from genotrance/tensorflow.nim
Nim wrapper for tensorflow using nimterop
# nim c -d:FLAGS tensorflow.nim
#
# FLAGS
# -d:capiDL
# -d:capiSetVer=
import os
import nimterop/[build, cimport]
@mowings
mowings / postgres_cache_hits.sql
Created January 26, 2023 15:09
Postgresql Cache hit ratio query
SELECT
sum(heap_blks_read) as heap_read,
sum(heap_blks_hit) as heap_hit,
sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as cache_hit_ratio
FROM pg_statio_user_tables;
@mowings
mowings / postgres_replication_lag.md
Last active January 20, 2023 16:09
Monitor postgres replication lag

Montioring postgres replication status

Use the following query at the source cluster to check status and lag (lag is in bytes):

select   application_name, pid, client_addr, state, sync_state,
         pg_wal_lsn_diff(sent_lsn, write_lsn) as write_lag,
         pg_wal_lsn_diff(sent_lsn, flush_lsn) as flush_lag,
         pg_wal_lsn_diff(sent_lsn, replay_lsn) as replay_lag
from pg_stat_replication;
@mowings
mowings / aurora-postgresq.txt
Created January 19, 2023 19:26
Get all db instance type availability for a region
aws --profile turbosquid-research rds describe-orderable-db-instance-options --engine aurora-postgresql \
--engine-version 13.4 --db-instance-class db.r6g.xlarge \
--region us-east-1