Skip to content

Instantly share code, notes, and snippets.

View garystafford's full-sized avatar
💭
Happily Coding!

Gary A. Stafford garystafford

💭
Happily Coding!
View GitHub Profile
@jdowning
jdowning / ami-clean.sh
Last active December 26, 2023 20:09
Script to clean up Ubuntu EC2 instance before packaging as an AMI
#!/bin/bash
# This script cleans up your EC2 instance before baking a new AMI.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.github.com/justindowning/5921369/raw/ami-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
@iconara
iconara / queries.sql
Last active November 13, 2023 22:26
Low level Redshift cheat sheet
-- Table information like sortkeys, unsorted percentage
-- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html
SELECT * FROM svv_table_info;
-- Table sizes in GB
SELECT t.name, COUNT(tbl) / 1000.0 AS gb
FROM (
SELECT DISTINCT datname, id, name
FROM stv_tbl_perm
JOIN pg_database ON pg_database.oid = db_id
@bluet
bluet / Database Naming Convention and Data Warehouse Design Principles.md
Last active November 13, 2023 13:12
Database Naming Convention and Data Warehouse Design Principles
@garystafford
garystafford / helpful-docker-commands.sh
Last active October 12, 2023 16:51
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@garystafford
garystafford / helpful-git-commands.sh
Last active May 17, 2023 00:34
Helpful git commands
###############################################################################
# Helpful Git/GitHub commands and code snippets
###############################################################################
#### Remove/Squash All History on Master - CAUTION! ####
# https://stackoverflow.com/a/26000395/580268
git checkout --orphan latest_branch \
&& git add -A \\
&& git commit -am "Remove/squash all project history" \
&& git branch -D master \
@nafeu
nafeu / python3-script-template.py
Created January 29, 2019 12:34
Python3 Terminal Script Template
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Template for python3 terminal scripts.
This gist allows you to quickly create a functioning
python3 terminal script using argparse and subprocess.
"""
import argparse
{
"Version": "2012-10-17",
"Statement": [{
"Action": "ec2:*",
"Effect": "Allow",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:Region": [
"us-east-1",
@jgautheron
jgautheron / One import via join.yaml
Created May 10, 2017 17:43 — forked from jespereneberg/One import via join.yaml
Fn::ImportValue from other stacks
Tags:
- Key: Name
Value:
!Join ['_', [ ec2, "Fn::ImportValue" : {"Fn::Sub":'${BaseStackName}-Environment'}, test2]]
#This will create a name tag with value: ec2_<yourValueFromOtherStack>_test2
@rmoff
rmoff / gist:f32543f78d821b25502f6db49eee9259
Created August 29, 2017 13:08
Kafka Connect JDBC source with JSON converter
{
"name": "jdbc_source_mysql_foobar_01",
"config": {
"_comment": "The JDBC connector class. Don't change this if you want to use the JDBC Source.",
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"_comment": "How to serialise the value of keys - here use the Json converter. We want to retain the schema in the message (which will generate a schema/payload JSON document) and so set schemas.enable=true",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"key.converter.schemas.enable":"true",