Skip to content

Instantly share code, notes, and snippets.

@captainsafia
captainsafia / mac_dev_setup.sh
Created August 14, 2018 01:06
A set of commands I use to configure my Mac for development
# Create a global gitignore for macOS
cat https://raw.githubusercontent.com/github/gitignore/master/Global/macOS.gitignore >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
# Send screenshots to a directory that isn't the desktop
mkdir -p ~/Screenshots
defaults write com.apple.screencapture location ~/Screenshots
# Show all hidden files (like dotfiles)
defaults write com.apple.finder AppleShowAllFiles YES; killall Finder;
@burntcookie90
burntcookie90 / guide.md
Last active December 30, 2023 14:41
sanderson reading guide

Lots of books, here's a way to enjoy them! Just my suggestion, I found this to be a great way to get into the overall Cosmere.

Cosmere

  1. Mistborn Era 1
    1. The Final Empire
    2. The Well of Ascension
    3. The Hero of Ages
  2. Elantris (This is one of his first books, it has a noticabley different style, but the story is fun and has some Cosmere stuff for later)
  3. The Emporer's Soul: Elantris Novella
  4. Stormlight Archive #1 : The Way of Kings
@gene1wood
gene1wood / role_arn_to_session.py
Created December 29, 2016 17:38
Simple python function to assume an AWS IAM Role from a role ARN and return a boto3 session object
import boto3
def role_arn_to_session(**args):
"""
Usage :
session = role_arn_to_session(
RoleArn='arn:aws:iam::012345678901:role/example-role',
RoleSessionName='ExampleSessionName')
client = session.client('sqs')
"""
from botocore.credentials import RefreshableCredentials
from botocore.session import get_session
from boto3 import Session
def assumed_session(role_arn, session_name, session=None):
"""STS Role assume a boto3.Session
With automatic credential renewal.
@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
@Kartones
Kartones / postgres-cheatsheet.md
Last active April 25, 2024 16:50
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@jszmajda
jszmajda / 1readme.md
Last active September 3, 2022 18:33
Data Serialization: JSON, MsgPack, ProtoBufs
@hummus
hummus / gist:8592113
Last active February 8, 2024 07:35
aws cli + jq example
wget http://stedolan.github.io/jq/download/linux64/jq
aws ec2 describe-instances --filters "Name=tag:Name,Values=$NAME" \
"Name=instance-state-name,Values=running" \
| jq -r \
".Reservations[] | .Instances[] | .InstanceId" \
aws ec2 describe-volumes --filters \
"Name=status,Values=available" \
| jq -r ".Volumes[] | .VolumeId" \
@krak3n
krak3n / gist:5884562
Last active March 2, 2019 19:37
Mocking open for ConfigParser.RawConfigParser.readfp() for unit testing.
import io
import six
from mock import patch
from six.moves import configparser as ConfigParser
data = """
[section]
key = value
"""
# A generic, single database configuration.
[application]
config_file_name = app_conf.py
[alembic]
# path to migration scripts
script_location = foo.bar:migrations
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s