Skip to content

Instantly share code, notes, and snippets.

View nstielau's full-sized avatar

Nick Stielau nstielau

  • Red Hat
  • San Francisco
View GitHub Profile
@nstielau
nstielau / post-receive
Created November 21, 2011 21:19
A post receive hook to sync remote non-bare repos
# First allow pushing to the checked-out branch on the remote repo:
# git config receive.denyCurrentBranch ignore
# Then add this to sync the working dir to the repo on receive:
GIT_WORK_TREE=/opt/titan GIT_DIR=/opt/titan/.git git reset --hard
# Then, on the local working dir, add the remote:
# git remote add test [email protected]:/opt/titan
@nstielau
nstielau / wp-config.php
Created November 16, 2011 02:11
wp-config.php for Wordpress on Pantheon
<?php
// Tweak #1
// Load database settings from PRESSFLOW_SETTINGS environment variable...
$pressflow_settings = json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE);
$database_settings = $pressflow_settings['databases']['default']['default'];
/** MySQL configs */
define('DB_NAME', $database_settings['database']);
define('DB_USER', $database_settings['username']);
define('DB_PASSWORD', $database_settings['password']);
@nstielau
nstielau / check_ohai_load_times.rb
Created October 28, 2011 21:22
Check the load times of Ohai plugins
#!/usr/bin/env ruby
# Check on the load times for Ohai plugins.
# To disable from chef-solo and chef-client runs see
# http://wiki.opscode.com/display/chef/Disabling+Ohai+Plugins
require 'benchmark'
require 'rubygems'
require 'ohai'
@nstielau
nstielau / alert_payload.json
Created July 11, 2011 13:43
A Sinatra app that for Cloudkick webhooks.
{
"node": {
"provider_id": 999,
"name": "i-12345678",
"state": 2,
"details": {
"status": ["running"],
"productcode": ["[]"],
"instanceId": ["i-12345678"],
"dns_name": ["ec2-174-123-210-12.compute-1.amazonaws.com"],
@nstielau
nstielau / bash.sh
Created June 2, 2011 20:55
Set node attributes, run_list, chef_environment, etc
knife node configure my_node.example.com
@nstielau
nstielau / default.rb
Created May 18, 2011 16:22
A simple Chef recipe to install Jenkins
#
# Cookbook Name:: jenkins
# Recipe:: default
#
# https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
# This is super-simple, compared to the other Chef cookbook I found
# for Jenkins (https://github.com/fnichol/chef-jenkins).
#
# This doesn't include Chef libraries for adding Jenkin's jobs via
@nstielau
nstielau / send_metric_to_statsd.sh
Created May 11, 2011 16:41
Send a metric to StatsD from bash
# Send a metric to statsd from bash
#
# Useful for:
# deploy scripts (http://codeascraft.etsy.com/2010/12/08/track-every-release/)
# init scripts
# sending metrics via crontab one-liners
# sprinkling in existing bash scripts.
#
# netcat options:
# -w timeout If a connection and stdin are idle for more than timeout seconds, then the connection is silently closed.
@nstielau
nstielau / Bash example
Created May 10, 2011 17:23
A Chef report_handler and knife plugin to persist and query updated actions
Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node log nstielau_vagrantup.com
Time Recipe Action Resource Type Resource
Tue May 10 10:25:20 -0700 2011 nginx::source create template proxy.conf
Tue May 10 10:25:20 -0700 2011 nginx::source enable service nginx
Tue May 10 09:50:42 -0700 2011 nginx::source create template /etc/init.d/nginx
@nstielau
nstielau / set_environment.rb
Created May 9, 2011 00:04
A Knife plugin to set node environment
## Knife plugin to set node environment
# See http://wiki.opscode.com/display/chef/Environments
#
## Install
# Place in .chef/plugins/knife/set_environment.rb
#
## Usage
# Nick-Stielaus-MacBook-Pro:chef-repo nstielau$ knife node set_environment mynode.net my_env
# Looking for mynode.net
# Setting environment to my_env
module Mongoid
module Processable
extend ActiveSupport::Concern
included do
@action = :process
@timeout = 60
@query = {}
field :processable, :type => Hash, :default => {:processable => {:locked_by => nil, :locked_at => nil, :last_error => nil}}
end