Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jameskyle
jameskyle / shebang.vim
Created November 15, 2011 15:40
Insert shebang at the top of new script files
augroup Shebang
au!
autocmd BufNewFile *.py 0put =\"#!/usr/bin/env python\<nl># -*- coding: iso-8859-15 -*-\<nl>\"|$
autocmd BufNewFile *.rb 0put =\"#!/usr/bin/env ruby\<nl># -*- coding: None -*-\<nl>\"|$
autocmd BufNewFile *.tex 0put =\"%&plain\<nl>\"|$
autocmd BufNewFile *.\(cc\|hh\) 0put =\"//\<nl>// \".expand(\"<afile>:t\").\" -- \<nl>//\<nl>\"|2|start!
augroup END
@jameskyle
jameskyle / manual bonding configuration.sh
Created June 26, 2012 20:04
manual bonding configuration
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
@jameskyle
jameskyle / stop_firewall.sh
Created September 4, 2012 22:20
Drop and flush all firewall rules and tables.
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
@jameskyle
jameskyle / chef_server_install.sh
Created November 8, 2012 15:51
Hands off installation of chef server + nginx https proxy
#!/bin/bash
CHEF_SERVER_WEBUI_PASS=webui_admin_pass
CHEF_AMQP_PASS=amqp_pass
CHEF_FQDN=chef.yourdomain.com
CHEF_URL=https://${CHEF_FQDN}
export DEBIAN_FRONTEND=noninteractive
echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | tee /etc/apt/sources.list.d/opscode.list
mkdir -p /etc/apt/trusted.gpg.d
@jameskyle
jameskyle / foo.rb
Created November 10, 2012 18:14
Object wrapper for the EC2 Metadata URL on Openstack & EC2 vm's
class EC2Metadata
def initialize()
meta_url = "169.254.169.254"
@meta_base = "/2008-02-01/meta-data/"
@conn = Net::HTTP.new(meta_url)
end
def method_missing(name, *args)
name = name.to_s.gsub("_", "-")
req = get_url(name)
@jameskyle
jameskyle / openstack.rb
Created November 14, 2012 01:49
Ohai plugin to collect openstack metadta (should work for ec2 as well)
require 'net/http'
provides "openstack"
openstack Mash.new
META_IP = "169.254.169.254"
BASE = "/latest/"
HTTP = Net::HTTP.new(META_IP)
HTTP.open_timeout = 1
@jameskyle
jameskyle / bootstrap.sh
Created December 6, 2012 04:03
tiny setup script for openstack
#!/bin/bash
IMAGE="7e572d23-6129-4f63-8454-8ab4995dd0e4"
KEY_NAME=my_key
#NOVARC=~/.cloud/blackflag-oauth-dev-dfw2-novarc
#source $NOVARC
NOVA=nova
M1_TINY=1 # 512MB ram
M1_SMALL=2 # 2GB ram

uwsgi

uwsgi --plugins http,python -s /tmp/mysock.sock -w gitpost:app \
      -H /var/www/blog.jameskyle.org/env/ --chmod-socket 777  \
      --buffer-size 32768 --catch-exceptions

nginx

d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string ops1.pao10.tfoundry.com
d-i netcfg/get_domain string razorlab.local
d-i netcfg/no_default_route boolean true
d-i user-setup/allow-password-weak boolean true
#Disable some questions
d-i user-setup/encrypt-home boolean false
global
maxconn 4096
nbproc 1
debug
daemon
log 127.0.0.1 local0
defaults
mode http
option httplog