Skip to content

Instantly share code, notes, and snippets.

View alexlovelltroy's full-sized avatar
🏫
Attending Marcel Marceau College of Radio Performance

Alex Lovell-Troy alexlovelltroy

🏫
Attending Marcel Marceau College of Radio Performance
View GitHub Profile
@alexlovelltroy
alexlovelltroy / create_vms.sh
Created February 21, 2019 16:11
Create, Load, and Start a bunch of simple firecracker vms
#!/bin/bash
echo "Bash version ${BASH_VERSION}..."
FIRECRACKER_BIN=/usr/bin/firecracker
JAILER_BIN=/usr/bin/jailer
echo -n "Jailer version "
$JAILER_BIN -V
echo -n "Firecracker version "
@alexlovelltroy
alexlovelltroy / reformat_json.py
Created September 6, 2018 14:13
Given a son file, reformat it as one data element per line
#!/usr/bin/env python3
import json
import sys
if __name__ == "__main__":
program_name = sys.argv[0]
arguments = sys.argv[1:]
count = len(arguments)
@alexlovelltroy
alexlovelltroy / create_gcp_data_project.sh
Created September 6, 2018 08:51
Bash snippet I use to create a temporary GCP project for doing datalab stuff
#!/usr/bin/bash
set -e
PROJECT_SUFFIX=$(cat /dev/random | LC_CTYPE=C tr -dc "a-z0-9" | head -c 5)
PROJECT_NAME=temp-project-$PROJECT_SUFFIX
PROJECT_BUCKET=data_export_bucket-$PROJECT_SUFFIX
# Update gcloud
@alexlovelltroy
alexlovelltroy / flap_nginx.py
Last active August 30, 2016 22:37
Python can reload the nginx config file faster than I can write a new one
#!/usr/bin/env python
import time
import psutil
import os
import signal
@alexlovelltroy
alexlovelltroy / pre-commit
Created September 24, 2015 13:13
A very simple pre-commit hook for continuous docker build
#!/bin/bash
# Add this locally to your repo as .git/hooks/pre-commit and make sure it is executable
# This does not actually get synced when you push to remote
docker build -t "hello_world" . && docker images hello_world && echo "Docker built properly"
# install cowsay and fortune
sudo apt-get install cowsay fortune
# install lolcat
sudo gem install lolcat
# be more wonderful
fortune |cowsay|lolcat
@alexlovelltroy
alexlovelltroy / custom.json
Created April 18, 2015 00:07
geoip and statsd example
"logstash": {
"version": "1.4.4",
"server": {
"enabled": true,
"inputs": [
{
"rabbitmq": {
"exchange": "logstash",
"user": "username",
"password": "password",
@alexlovelltroy
alexlovelltroy / test.rb
Created January 13, 2015 21:33
test opsworks
# use this file to run chef locally on an opsworks instance
# You'll need to put it in /opt/aws/opsworks/current <-- it should contain a bin/ subdir
# to use it, find reasonable paths for substitution and call your recipe like this:
# bin/chef-solo -o <cookbook>::<recipe> -c test.rb -j /var/lib/aws/opsworks/chef/<date>.json -l info
# The next line is the only thing you really need in this file. The rest is documentation
cookbook_path ["/opt/aws/opsworks/current/merged-cookbooks"]
@alexlovelltroy
alexlovelltroy / new_host.sh
Created December 19, 2014 14:27
How I Start
curl -LO https://raw.githubusercontent.com/alexlovelltroy/dotfiles/master/.screenrc
curl -LO https://raw.githubusercontent.com/alexlovelltroy/dotfiles/master/.gitconfig
curl -LO https://raw.githubusercontent.com/alexlovelltroy/dotfiles/master/.bash_profile
curl -L http://j.mp/spf13-vim3 -o - | sh
curl -L http://install.ohmyz.sh | sh
@alexlovelltroy
alexlovelltroy / reassign.sh
Created December 18, 2014 20:33
reallocate unassigned shards in elasticsearch
NODE="a hostname"
IFS=$'\n'
for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do
INDEX=$(echo $line | (awk '{print $1}'))
SHARD=$(echo $line | (awk '{print $2}'))
curl -XPOST 'localhost:9200/_cluster/reroute?pretty' -d '{
"commands": [
{
"allocate": {