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 / postgres-upgrade.sh
Created February 7, 2019 23:17
Testing Sourcegraph 3.0 db upgrade
#!/usr/bin/env bash
set -xeuo pipefail
export OLD=${OLD:-"9.6"}
export NEW=${NEW:-"11"}
export SRC_DIR=${SRC_DIR:-"$HOME/.sourcegraph"}
docker run \
-w /tmp/upgrade \
// Version that excludes Sourcegraphers and prints a markdown list with hyperlinks.
// Commented out code was experimenting with printing contributors for each relevant repository but as some repositories don't have issues, it wasn't used.
package main
import (
"context"
"fmt"
"log"
@ryan-blunden
ryan-blunden / textdoc.json
Created December 18, 2018 22:41
Sourcegraph TextDocument
// A page can have multiple editors that each have their own document, e.g. a PR.
{
"uri": "git://github.com/django/django?d6eaf7c0183cd04b78f2a55e1d60bb7e59598310#django/__init__.py",
"languageId": "python",
"text": "from django.utils.version import get_versionVERSION = (2, 0, 0, 'alpha', 0)__version__ = get_version(VERSION)def setup(set_prefix=True): \"\"\" Configure the settings (this happens as a side effect of accessing the first setting), configure logging and populate the app registry. Set the thread-local urlresolvers script prefix if `set_prefix` is True. \"\"\" from django.apps import apps from django.conf import settings from django.urls import set_script_prefix from django.utils.encoding import force_text from django.utils.log import configure_logging configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) if set_prefix: set_script_prefix( '/' if settings.FORCE_SCRIPT_NAME is None else force_text(settings.FORCE_SCRIPT_NAME) )
[
{
"region": "us-gov-west-1",
"amis": [
{
"id": "ami-7e7aea1f",
"type": "amzn2-ami-hvm-2.0.20180622.1-x86_64-ebs"
},
{
"id": "ami-3b48d85a",
@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
@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 / 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 / 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 / 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 / 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>"