Skip to content

Instantly share code, notes, and snippets.

View ryan-blunden's full-sized avatar

Ryan Blunden ryan-blunden

  • Brisbane, Australia
View GitHub Profile
@ryan-blunden
ryan-blunden / .bash_profile
Last active July 23, 2018 20:52
My .bash_profile on OSX
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
# User @ Host - working dir
export PS1="ryno: \w: "
export PS1="[\[\033[0;37m\]\u\[\033[0m\]] \w\n-> "
export TERM='xterm-color'
export CLICOLOR=1
export LC_CTYPE='en_US.UTF-8'
@ryan-blunden
ryan-blunden / hidden_files.sh
Created August 9, 2015 10:08
Bash alias for showing/hiding hidden files in OSX
# Adds an alias `hidden_files` that requires either YES or NO to indicate whether they should be shown or hidden
# Usage: hidden_files YES|NO
hidden_files_fn() {
defaults write com.apple.finder AppleShowAllFiles $1
}
alias hidden_files=hidden_files_fn
Below is a brief summary of the resources I mentioned in my talk.
Contact me on LinkedIn or Twitter (@ryan_blunden) if you want more info.
## Development environment
- virtualenv, virtualenvwrapper
- SSL for Django runserver (via django_extensions) - `./manage.py runserver_plus --cert conf/localhost 8081`
- SSL required if you have an iOS native app hitting your server and you don't want the iOS Devs to hack their Info.plist
- Run a local mailserver in your shell - `python -m smtpd -n -c DebuggingServer localhost:1025`
struct DateUtils {
static let isoDateFormatter: NSDateFormatter = NSDateFormatter()
static func toISO8601(date: NSDate) -> String {
isoDateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") // Why en_US_POSIX? - https://developer.apple.com/library/mac/qa/qa1480/
isoDateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZZ" // ISO8601 format
return isoDateFormatter.stringFromDate(date)
}
}
@ryan-blunden
ryan-blunden / aws-cli-auth.sh
Last active December 6, 2017 08:08
Convenience script for AWS CLI authentication requriing MFA
#! /usr/bin/env bash
# ---------------------------------------------------------------------
# [Author] Ryan Blunden and Aaron Addleman
# Convenience script for AWS CLI authentication requriing MFA
# ---------------------------------------------------------------------
VERSION=0.1.0
UPDATED=2017-11-07
USAGE="Usage: . ./bin/$(basename "$0") -a <account-number> -u <username> -t <mfa-token>"
@ryan-blunden
ryan-blunden / check_vars_list.sh
Created November 27, 2017 02:49
Check for the existence of a list of variables. List missing vars and exit with code 1 if any are not set. They can however, be empty.
#!/usr/bin/env bash
# Check required environment vars are set
required_vars=(DJANGO_SECRET_KEY DB_NAME DB_USER DB_PASSWORD DB_HOST DB_PORT CACHE_HOST CACHE_PORT)
missing_vars=()
for i in "${required_vars[@]}"
do
test -n "${!i+set}" || missing_vars+=("$i")
done
@ryan-blunden
ryan-blunden / Dockerfile
Last active June 5, 2018 05:06
The `pipenv install --deploy --system` command is no longer working.
FROM python:3-alpine3.6
RUN apk update && \
apk upgrade && \
apk add git
# Install pipenv from master
RUN pip install pip --upgrade && \
pip install pipenv
@ryan-blunden
ryan-blunden / rund.sh
Last active June 11, 2018 23:16
Simple bash function for running a throw-away Docker container for experimentation purposes
# Simple bash function for running a throw-away Dockert container for experimentation purposes
rund() { docker container run --rm -it $@; }
@ryan-blunden
ryan-blunden / port-processes.sh
Last active June 11, 2018 22:30
Get list of processes *listening on TCP ports using lsof
# -n means don't do hostname lookups for ip addresses
# -i is the protocol we're targetting (e.g. 6 (ipv6) or UDP)
# -P because we don't want host names as we want to search by port numbers (e.g. 8080 has a host name of "http-alt").
# If you want everything
lsof -n -P -iTCP | grep LISTEN
# Or if you want to limit it to a specfic port
lsof -n -P -iTCP:8080 | grep LISTEN
@ryan-blunden
ryan-blunden / kubernetes-dashboard-dev.sh
Last active August 12, 2018 14:20
Simple Kubernetes dashboard management for local development
#!/usr/bin/env bash
K8S_DASHBOARD_PORT=30000
k8s-dashboard-up () {
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
until kubectl get pods --namespace=kube-system | grep kubernetes-dashboard &> /dev/null
do
sleep 1