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 / 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": {
@alexlovelltroy
alexlovelltroy / command.sh
Created December 9, 2014 22:18
HTTP network testing with curl
# Graciously lifted from http://overloaded.io/timing-http-requests-curl
for i in {1..10};do curl -s -w @curl-format -o /dev/null "http://Www.pythian.com"; done
@alexlovelltroy
alexlovelltroy / hello.js
Created December 9, 2014 20:19
nodejs hello world
var http = require("http");
var url = require("url");
function start() {
function onRequest(request, response) {
var pathname = url.parse(request.url).pathname;
console.log("Request for " + pathname + " received.");
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World at " + pathname);
@alexlovelltroy
alexlovelltroy / civil_discussion.md
Created November 26, 2014 18:00
Rules for civilized discussion

don't be a jerk