Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
cat /dev/urandom | base64 | sed 's/[^A-Za-z0-9]//' | head -c 8
@forbesmyester
forbesmyester / nginx-proxy-dns
Last active August 29, 2015 14:22
Adds hosts which are generated for `https://github.com/jwilder/nginx-proxy` to your local /etc/hosts file (tested in Ubuntu)
#!/bin/bash
export DOCKER_GEN_VERSION="0.3.9"
# Generates a new /etc/hosts whenever a docker host is added with a VIRTUAL_HOST environmental variable ( see super useful project at https://github.com/jwilder )
# Code here shamelessly stolen from
# * https://github.com/jwilder/nginx-proxy/blob/master/Dockerfile
# * http://unix.stackexchange.com/questions/81685/how-to-remove-multiple-newlines-at-eof
@forbesmyester
forbesmyester / quick_unit_tests
Last active December 24, 2015 10:54
Quick Unit Tests in Docker
#!/bin/bash
# Run tests (or anything else) in Docker by doing a tagged build and then run, which should make things much faster.
#
# @author forbesmyester
# @license MIT
DOCKER_TAG=$(echo $PWD | tr '[:upper:]' '[:lower:]' | sed 's/^\///' | sed 's/\//-/g')
echo ""
echo "== USING DOCKER TAG: test-$DOCKER_TAG =========================="
@forbesmyester
forbesmyester / remove_all_es_indices
Last active December 30, 2015 23:32
Bash to remove all ES indices
#!/bin/bash
curl 'localhost:9200/_cat/indices?v' | awk '{ print $3 }' | grep -v '^\.' | tr '\n' '\0' | xargs -n 1 -0 -I {} curl -X DELETE "http://localhost:9200/{}"
# from https://twitter.com/jpetazzo/status/347431091415703552
docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs docker rm
@forbesmyester
forbesmyester / raw_image_convert
Last active January 13, 2016 21:17
Raw Image Converter
#!/bin/bash
MAX_SIZE=1920
RAWS=$(find | grep RW2 | grep -v '\.jpg\.RW2')
for RAW in $RAWS; do
LOCKFILE=$(echo "$RAW" | sed 's/\.RW2$/.jpg.RW2/')
OUTFILE=$(echo "$RAW" | sed 's/\.RW2$/.jpg/')
echo $OUTFILE
if [ ! -e "$OUTFILE" ]; then
package main
// from https://tour.golang.org/methods/25
import (
"golang.org/x/tour/pic";
"image";
"image/color"
)
@forbesmyester
forbesmyester / golang-tour-concurrency-8.go
Created November 29, 2017 12:12
The Go Tour - Concurrency 8
package main
import (
"golang.org/x/tour/tree"
"fmt"
)
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
@forbesmyester
forbesmyester / Dockerfile
Created February 9, 2018 14:31
Quick Docker PHP PostgreSQL
FROM php:7.2.2-apache
RUN apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pgsql
COPY ./ /var/www/html
@forbesmyester
forbesmyester / view-pg-permissions-across-schema.sql
Last active March 6, 2018 10:35
View permissions of Users in PostgreSQL across schema / database
with
table_list as (select table_catalog, table_schema, table_name from information_schema.tables where table_schema not in ('information_schema', 'pg_catalog')),
permissions as (
select
grantee,
table_catalog,
table_schema,
table_name,
is_grantable,
privilege_type::varchar