Skip to content

Instantly share code, notes, and snippets.

@eric
eric / linux_proc_name.rb
Created November 9, 2011 07:39
Update a process name in linux to change how it shows up in top and lsof
#
# Eric Lindvall <[email protected]>
#
# Update the process name for the process you're running in.
#
# This will allow top, lsof, and killall to see the process as the
# name you specify.
#
# Just use:
#
@stevendanna
stevendanna / default.rb
Created October 11, 2011 16:33
Monkey patching the Template resource to do validation
#
# Cookbook Name:: template_checker
# Recipe:: default
#
# Copyright 2011, Opscode, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@jonathonbyrdziak
jonathonbyrdziak / Instructions
Created October 10, 2011 08:02
The perfect magento installation on CentOS 6
#
# @author Jonathon byrd
#
############################################################
# first things first, set your iptables for a web server. If you jack these
# up you don't want to have to re-install your os after doing much more.
# @see http://www.thegeekstuff.com/2011/06/iptables-rules-examples/
# and
# @see https://help.ubuntu.com/community/IptablesHowTo
@jtimberman
jtimberman / config.rb
Created September 26, 2011 16:53
Put this in the config file (/etc/chef/client.rb, ~/.chef/knife.rb, etc)
confd = File.join(File.dirname(__FILE__), "conf.d", "*.rb")
clientd = File.join(File.dirname(__FILE__), "client.d", "*.rb")
[ Dir.glob(confd), Dir.glob(clientd) ].each do |confs|
confs.each {|f| Chef::Config.from_file(f)}
end
@tobert
tobert / ruby-taskset.sh
Created August 1, 2011 18:11
Improve ruby's performance by locking to a single CPU
#!/bin/bash
# Ruby's GIL is a liability when actually doing CPU work
# on a large SMP machine, doubly so on NUMA. This works around it.
# Ruby processes are locked onto a single core + its HT sibling
# on intel machines, 2 cores on AMD. Ideally this would lock to
# one core on non-HT processors, but all of mine are HT so it WFM.
max_cpu=$(cat /proc/cpuinfo |awk -F ': ' '/processor/{print $2}' |tail -n 1)
@russss
russss / gist:1064891
Created July 5, 2011 14:04
Git post-receive hook to post commit details to an AMQP topic
#!/usr/bin/env python
""" Git post-receive hook to publish commit data to an AMQP topic.
apt-get install python-git python-amqplib
or:
easy_install amqplib gitpython
"""
import os, sys, json
from datetime import datetime
from git import *
@fujin
fujin / ebs_raid6_provider.rb
Created May 8, 2011 03:20
aws_ebs_raid6 lwrp
include Chef::Mixin::Command
action :create do
size = new_resource.size
volumes = new_resource.volumes.times.map{|i| (i == 0 ? "/dev/sdf" : "/dev/sdf#{i}") }
setra = new_resource.blockdev_setra
volume_group = new_resource.volume_group
logical_volume = new_resource.name
mdadm_device = new_resource.mdadm_device
mount_point = new_resource.mount_point
@tnine
tnine / ebs_raid.rb
Created April 27, 2011 03:03
Ebs raid mounting. Links to this jira issue http://tickets.opscode.com/browse/CHEF-2275
include Opscode::Aws::Ec2
#Auto locates and attached ebs devices based on the data bag they reside in. The following test cases need to be performed
# Create multiple resources with new node: PASS
#
# Re-attach multiple resources after a reboot: PASS
#
# Create resources across 2 runs. First run creates first raid set, second run re-attaches then creates: PASS
#
@roidrage
roidrage / mantras.md
Created April 21, 2011 16:18
7 Mantras of Successful Infrastructure
  • The network is reliable.
  • Latency is zero.
  • Bandwidth is infinite.
  • The network is secure.
  • Topology doesn't change.
  • There is one administrator.
  • Transport cost is zero.
  • The network is homogeneous.
@octplane
octplane / changes.sh
Created April 19, 2011 15:54
Quickly upload changes to a chef server (0.8)
#!/bin/sh
diff -x .gitignore -x .DS_Store -x metadata.json -x "README" -qr cookbooks/ /srv/chef/cookbooks/ | grep -v "Only in
/srv/chef/cookbooks/" | sed -e "s/.*cookbooks\/[ :]*//;s/\/.*//;s/:.*//" | sort | uniq | xargs knife cookbook upload
for a in `diff -x .gitignore -x metadata.json -x "README" -qr cookbooks/ /srv/chef/cookbooks/ | grep "Only in /srv/
chef/cookbooks/" | sed -e "s/.*cookbooks\/[ :]*//;s/\/.*//;s/:.*//" | sort | uniq`; do
echo "y" | knife cookbook delete $a
done