Skip to content

Instantly share code, notes, and snippets.

@hattwj
hattwj / docker-compose-to-etc-hosts
Last active August 22, 2022 16:29
Quickly add hostname aliases for running docker-compose containers
#!/usr/bin/env bash
# Run this file on the host machine that is running dockerd
# It will allow you to access your docker containers via hostname aliases
# Remove old lines with suffix
sed -i -e "/#docker-temp/d" /etc/hosts
# Collect ip-addresses and hostnames of running docker-compose containers
ADDR=$(docker-compose ps -q | xargs --no-run-if-empty -I --- docker exec --- hostname -I| sed -e 's/ /-/')
@wsargent
wsargent / docker_cheat.md
Last active August 31, 2023 12:10
Docker cheat sheet
@inklesspen
inklesspen / README.md
Last active September 6, 2023 17:11
Fast and flexible unit tests with live Postgres databases and fixtures

(This gist is pretty old; I've written up my current approach to the Pyramid integration on this blog post, but that blog post doesn't go into the transactional management, so you may still find this useful.)

Fast and flexible unit tests with live Postgres databases and fixtures

I've created a Pyramid scaffold which integrates Alembic, a migration tool, with the standard SQLAlchemy scaffold. (It also configures the Mako template system, because I prefer Mako.)

I am also using PostgreSQL for my database. PostgreSQL supports nested transactions. This means I can setup the tables at the beginning of the test session, then start a transaction before each test happens and roll it back after the test; in turn, this means my tests operate in the same environment I expect to use in production, but they are also fast.

I based my approach on [sontek's blog post](http://sontek.net/blog/