Skip to content

Instantly share code, notes, and snippets.

$ docker exec -i $CONTAINER pg_restore --dbname=$DATABASE --verbose --clean -U $USER < pg_dump --format custom $DATABASE
#!/usr/bin/env sh
# checks to see if running
launchctl list | grep elasticsearch
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.elasticsearch.plist
launchctl remove homebrew.mxcl.elasticsearch
pkill -f elasticsearch
# .style.yapf
#
# DESCRIPTION
# Configuration file for the python formatter yapf.
#
# This configuration is based on the generic
# configuration published on GitHub.
#
# AUTHOR krnd
# VERSION v1.0
@jhrr
jhrr / merge-repos.sh
Created May 20, 2019 19:50
Methods to merge two git repos into one.
# Brings over all tags/branches keeping history intact for the
# incoming remote data.
$ cd path/to/source-repo
$ git remote add target path/to/target
$ git fetch target --tags
$ git merge --allow-unrelated-histories target/some-branch
$ git remote remove target
# Or, to merge just the one branch this works but it loses all
# the extra history that the above method preserves.
@jhrr
jhrr / restore.sh
Created March 18, 2019 16:58 — forked from jgillman/restore.sh
pg_restore a local db dump into Docker
# Assumes the database container is named 'db'
DOCKER_DB_NAME="$(docker-compose ps -q db)"
DB_HOSTNAME=db
DB_USER=postgres
LOCAL_DUMP_PATH="path/to/local.dump"
docker-compose up -d db
docker exec -i "${DOCKER_DB_NAME}" pg_restore -C --clean --no-acl --no-owner -U "${DB_USER}" -d "${DB_HOSTNAME}" < "${LOCAL_DUMP_PATH}"
docker-compose stop db
$ docker-compose down
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker rm $(docker ps -a -q)
$ brew install postgresql
$ brew services start postgresql
$ initdb /usr/local/var/postgres -E utf8 --locale=en_GB.UTF-8
$ psql -h localhost -d postgres
# Emacs daemon functions.
emacs_server_ok() {
emacsclient -a "false" -e "(boundp 'server-process)";
}
# Open a file, in the current shell, using the emacs daemon.
e() {
if [[ "${1}" == '' ]]; then
emacsclient --tty .
TESTING-C(7) FreeBSD Miscellaneous Information Manual TESTING-C(7)
NAME
Testing C – a simple unit testing setup
DESCRIPTION
This is a simple approach to unit testing in C that I've used in a couple
projects. At the bottom of a C file with some code I want to test, I
add:
@jhrr
jhrr / delay.c
Last active November 27, 2018 13:14
static double D[M]; /* initialized to zero */
static long ptr=0; /* read-write offset */
double delayline(double x) {
double y = D[ptr]; /* read operation */
D[ptr++] = x; /* write operation */
// *(ptr++) = x; ??
if (ptr >= M) {
ptr -= M; /* wrap ptr */
}