Skip to content

Instantly share code, notes, and snippets.

View jcderr's full-sized avatar

Jeremy Derr jcderr

  • Amsterdam
View GitHub Profile
@jcderr
jcderr / aws_storages.py
Created February 24, 2014 15:13
Using django-storages to put MEDIA in S3, STATICFILES in Cloudfront
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class UserMediaS3Storage(S3BotoStorage):
def __init__(self, *args, **kwargs):
# if we set settings.AWS_S3_BUCKET, it will interfere with storagres.backends.s3boto.S3BotoStorage
# rendering of our {% static %} assets. So, we're leaving that unset and getting our bucket from
# another settings var.
kwargs['bucket'] = getattr(settings, 'USER_MEDIA_STORAGE_BUCKET')
@jcderr
jcderr / keybase.md
Created October 8, 2014 20:16
keybase.md

Keybase proof

I hereby claim:

  • I am jcderr on github.
  • I am jcderr (https://keybase.io/jcderr) on keybase.
  • I have a public key whose fingerprint is 7747 17ED 92D9 B883 2DBC 9915 13DF C428 CF1C 80DC

To claim this, I am signing this object:

devserver:
image: << production docker image name >>
volumes:
- .:/usr/src/app
links:
- db
- redis
environment:
DEBUG: True
DATABASE_URL: postgres://username:password@db:5432/dbname
@jcderr
jcderr / znc.service
Last active August 29, 2015 14:12
ZNC Systemd Unit
[Unit]
Description=ZNC
Requires=docker.service
After=docker.service
[Service]
User=core
ExecStartPre=-/usr/bin/docker stop znc
ExecStartPre=-/usr/bin/docker rm znc
ExecStart=/usr/bin/docker run --name znc -p 36667:6667 -v ${HOME}/.znc:/znc-data jimeh/znc
@jcderr
jcderr / vpnroute.sh
Created March 13, 2015 21:06
vpnroute.sh
#!/bin/bash
GATEWAY=$(ifconfig | grep 192.168 | grep "\-\->" | awk '{ print $2 }')
sudo /sbin/route add -net 10.0.0.0 -netmask 255.0.0.0 -gateway $GATEWAY
@jcderr
jcderr / kube-apiserver.service
Created July 15, 2015 15:21
CoreOS Units for upgrading Kubernetes Master
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=setup-network-environment.service etcd2.service generate-serviceaccount-key.service
After=setup-network-environment.service etcd2.service generate-serviceaccount-key.service
[Service]
EnvironmentFile=/etc/network-environment
ExecStartPre=-/usr/bin/mkdir -p /opt/bin
ExecStartPre=-/usr/bin/mv /opt/bin/kube-apiserver /opt/bin/kube-apiserver.backup
@jcderr
jcderr / wupiao
Created July 30, 2015 16:46
[W]ait [U]ntil [P]ort [I]s [A]ctually [O]pen
#!/bin/bash
# usage: wupiao [ip] [port]
# inspired by script of same name from Kubernetes project
# we're going to test any port, though, not just HTTP
[ -n "$1" ] && [ -n "$2" ] && while ! nc -z $1 $2; do sleep 1 && echo -n .; done;
exit $?
@jcderr
jcderr / w200
Last active January 26, 2016 18:43
wait until server/url responds with 200
#!/bin/bash
URL=$1
CODE="200"
[[ -n "$URL" ]] || { echo "Please specify a URL to watch"; exit 1; }
[[ -n "$2" ]] && CODE=$2
while true; do
STATUS=$(curl -o /dev/null --insecure --silent --head --write-out '%{http_code}' ${URL})
@jcderr
jcderr / nginx-conf.d-conf-file
Last active January 15, 2019 16:50
Kubernetes Nginx Gateway with Upstreams from ConfigMap
include /etc/nginx/conf.d/upstreams/*.conf;
server {
listen 8080;
resolver 10.99.254.254;
server_name ~^(?<svc>[a-zA-Z0-9]+)(?<env>[\-a-zA-Z0-9]*)\..*\.com$;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@jcderr
jcderr / wuamid
Created July 12, 2016 14:50
(W)ait (U)ntil (AMI) (D)one
#!/bin/zsh
autoload colors
if [[ "$terminfo[colors]" -gt 8 ]]; then
colors
fi
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval ${COLOR}='$fg_no_bold[${(L)COLOR}]'
eval BOLD_${COLOR}='$fg_bold[${(L)COLOR}]'