Skip to content

Instantly share code, notes, and snippets.

View justisGipson's full-sized avatar
👽

justisGipson

👽
View GitHub Profile
@justisGipson
justisGipson / heroku_pg_metrics.py
Last active October 7, 2024 21:43
heroku postgres metrics
import sys
import time
from subprocess import CalledProcessError, check_output
def convert_bytes_to_gb(bytes_value):
return round(bytes_value / 1000000000, 2)
def convert_kb_to_gb(kb_value):
@justisGipson
justisGipson / docker_example.md
Last active August 27, 2024 17:24
example Docker & Compose files

Dockerfile:

FROM node:20.10.0-alpine3.17 AS base

RUN apk update && \
   apk add --no-cache postgresql-client && \
   rm -rf /var/cache/apk/*

WORKDIR /usr/src/app
@justisGipson
justisGipson / ubuntu-cleanup.md
Last active July 3, 2024 12:58
ubuntu cleanup
sudo apt-get clean;
sudo apt-get autoclean;
sudo journalctl --vacuum-size=50M;

sudo apt-get autoremove --purge;

sudo docker system prune -a;

sudo apt-get purge $(dpkg -l 'linux-image-*' | awk '/^ii/ && !/'$(uname -r)'/ {print $2}');
@justisGipson
justisGipson / April 17, 2024.md
Last active April 19, 2024 18:51
uh, fresh docker + git install on new machine

add Docker's official GPG key:

sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc

add the repository to apt sources:

echo
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \

@justisGipson
justisGipson / tf_vars_sort.awk
Last active May 14, 2025 18:47 — forked from yermulnik/tf_vars_sort.awk
Sort Terraform (HCL) file by Resource Block Names using GNU `awk`
#!/usr/bin/env -S awk -f
# Usage: /path/to/tf_vars_sort.awk < variables.tf | tee sorted_variables.tf
# Note: "chmod +x /path/to/tf_vars_sort.awk" before use
{
# skip blank lines at the beginning of file
if (!resource_type && length($0) == 0) next
# pick only known Terraform resource definition block names of the 1st level
# https://github.com/hashicorp/terraform/blob/main/internal/configs/parser_config.go#L55-L163
switch ($0) {
@justisGipson
justisGipson / activity_table_queries.md
Last active March 12, 2024 19:43
user usage query examples for data collection initiative

Unique Logins From Activity Table:

SELECT COUNT(DISTINCT "userId") AS unique_logins
FROM activity
WHERE
  "createdAt" >= now() - INTERVAL '3 months' -- or "createdAt" BETWEEN '2022-01-01' AND '2024-03-10'
  AND "userId" NOT IN (
    SELECT id FROM users
    WHERE
      "email" LIKE '%@ellipsiseducation.com%'
@justisGipson
justisGipson / Procfile.md
Last active June 27, 2024 12:46
beanstalk dummy files
web: npm start # or whatever the start command is
@justisGipson
justisGipson / aws_grafana_promql.md
Last active March 13, 2024 15:08
grafana PromQL AWS metrics

Latency

CloudFront

Average Origin Latency:

avg_over_time(aws_cloudfront_origin_latency{<DIMENSION NAME="DIMENSION VALUE">}[5m])

Elastic Beanstalk

Application Latency p99:

@justisGipson
justisGipson / jsonpath_examples.md
Last active February 16, 2024 16:04
jsonPath cheatsheet - example queries
  1. Extract all name fields: $[*].name

  2. Find object with a specific id (e.g., id 15): $[?(@.id==15)]

  3. Extract defaultRegion from all jsonData: $[*].jsonData.defaultRegion

  4. Filter objects by authType inside jsonData where authType is keys:

@justisGipson
justisGipson / iterm2.md
Created December 3, 2023 19:48 — forked from squarism/iterm2.md
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)