Skip to content

Instantly share code, notes, and snippets.

@duggan
duggan / redis.sh
Last active December 15, 2015 06:09
Process management of redis-server on OSX.
#!/bin/sh
##
# Process management for Redis on OSX
#
# To install:
#
# git clone https://gist.github.com/5214562.git && \
# mv 5214562/redis.sh /usr/local/bin/redis && \
# chmod +x /usr/local/bin/redis
@duggan
duggan / install.sh
Last active March 3, 2019 21:08
Setup ArchiveTeam Warrior supervisor config (Ubuntu EC2)
#!/bin/bash
USERDATA=$(ec2metadata --user-data)
NICKNAME="hackernews"
if [ "$USERDATA" != "unavailable" ] ; then
NICKNAME=$USERDATA
fi
# Setup Supervisor
echo "[program:warrior]
@duggan
duggan / setup.sh
Last active March 3, 2019 21:08
Setup script for Archive Warrior Yahoo Messages SpotInstance AMI
#!/bin/bash
set -o nounset
set -o errexit
# Install dependencies
apt-get update
apt-get install -y build-essential lua5.1 liblua5.1-0-dev python python-setuptools python-dev git-core openssl libssl-dev python-pip rsync gcc make git supervisor
pip install seesaw
git clone https://github.com/ArchiveTeam/yahoomessages-grab
@duggan
duggan / active
Created March 27, 2013 23:49
Current Archive Warrior Project(s)
- git://github.com/ArchiveTeam/yahoomessages-grab.git
@duggan
duggan / removegems.sh
Created April 9, 2013 18:31
Remove all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@duggan
duggan / envclean.sh
Last active December 16, 2015 21:48
Envclean helps nuke and reseed a ruby environment for development purposes using rbenv and bundler. Add it to your PATH.
#!/bin/sh
set -o nounset
set -o errexit
help() {
printf "envclean - managing ruby environments
envclean list list available ruby versions (uses rbenv).
envclean for RUBY_VERSION cleans and initializes a specific ruby version.
@duggan
duggan / gist:5629873
Created May 22, 2013 18:40
/usr/local/bin/composer
#!/bin/sh
/usr/bin/env php -d allow_url_fopen=On -d detect_unicode=Off /data/homedirs/deploy/build/composer.phar $*
@duggan
duggan / nginx-setup.sh
Last active December 18, 2015 09:49
Add nginx official deb sources
apt-get install -y curl
# Install nginx
if [ "xx" = "x$(grep 'nginx' /etc/apt/sources.list )x" ] ; then
echo 'Installing nginx...'
echo '
# Repositories for up to date nginx packages
deb http://nginx.org/packages/mainline/ubuntu/ precise nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ precise nginx' >> /etc/apt/sources.list
curl -s http://nginx.org/keys/nginx_signing.key | apt-key add -
apt-get update > /dev/null
@duggan
duggan / replace.sh
Last active October 16, 2018 13:34
Using sed to to find/replace in a file in a portable way.
#!/bin/sh
# Usage: replace "foo" "bar" "/etc/omg.conf"
replace() {
local pattern=$1
local replacement=$2
local file=$3
local tempfile="$(mktemp -t temp.XXXXX)"
sed "s/$pattern/$replacement/" ${file} > ${tempfile} && mv ${tempfile} ${file}
@duggan
duggan / Vagrantfile
Last active December 18, 2015 11:09 — forked from wizardishungry/Gemfile
Vagrant (v1.1+) snippet to set VirtualBox guest CPU count to the number of host cores on Linux or OS X
# -*- mode: ruby -*-
# vi: set ft=ruby :
if not RUBY_PLATFORM.downcase.include?("mswin")
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--cpus",
`awk "/^processor/ {++n} END {print n}" /proc/cpuinfo 2> /dev/null || sh -c 'sysctl hw.logicalcpu 2> /dev/null || echo ": 2"' | awk \'{print \$2}\' | cut -d' ' -f2 `.chomp ]
end
end