Skip to content

Instantly share code, notes, and snippets.

View jtimberman's full-sized avatar
🚀

Joshua Timberman jtimberman

🚀
View GitHub Profile
@lusis
lusis / chef-listener.rb
Created May 19, 2012 07:35
The stupid hacky chef-listener I used in my talk at #chefconf
require 'webmachine'
require 'celluloid'
require 'json'
class ChefRunner
include Celluloid
def initialize(name)
@to_run = 0
@running = false
@danielsdeleo
danielsdeleo / resource_display.rb
Created May 22, 2012 19:45
Print a list of resources with the attributes filled in from node attrs, search, etc.
# (sudo) knife exec -c /etc/chef/client.rb resource_display.rb [FILTER]
# This will update the recipes and such on your machine, but it shouldn't make any real changes.
# Coded in 10 minutes, use at your own risk.
require 'chef/client'
require 'chef/checksum_cache'
require 'chef/provider'
require 'chef/providers'
require 'chef/resource'
require 'chef/resources'
@coderanger
coderanger / __init__.py
Created June 11, 2012 00:57
Edited version of opscode's fabfile/
import os
from fabric.api import env, task, roles, run
from fabric.utils import abort
from chef import ChefAPI, autoconfigure
from chef.fabric import chef_roledefs
if 'OC_USER' in os.environ:
env.user = os.environ['OC_USER']
@danielsdeleo
danielsdeleo / gist:2920702
Created June 12, 2012 23:06
Eval and Converge a Single Chef Recipe
#!/usr/bin/env ruby
recipe_path = ARGV[0]
if recipe_path.nil?
STDERR.puts "usage: chef-apply RECIPE_FILE"
exit 1
end
recipe_path = File.expand_path(recipe_path)
@ctdk
ctdk / github.js.diff
Created June 13, 2012 17:39
Diff to fix Octopress' github.js to make it not use the deactivated Github v2 API
diff --git a/source/javascripts/github.js b/source/javascripts/github.js
index 678775a..bc4c9bd 100644
--- a/source/javascripts/github.js
+++ b/source/javascripts/github.js
@@ -3,22 +3,22 @@ var github = (function(){
var i = 0, fragment = '', t = $(target)[0];
for(i = 0; i < repos.length; i++) {
- fragment += '<li><a href="'+repos[i].url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
+ fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+repos[i].description+'</p></li>';
@atomic-penguin
atomic-penguin / symbol_to_string.sh
Created June 21, 2012 20:35
Foodcritic FC001 fixer script.
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Usage: `basename $0` <cookbook directory>"
elif [ "$#" -eq 1 ]; then
find $1 -name "*[.md|.rb]" ! -name "*.git" ! -name "*.erb" | xargs perl -p -e 's!\[:([a-z0-9_]+)\]![\x27$1\x27]!gi' -i
echo "Commit message:"
echo "FC001: Use strings in preference to symbols to access node attributes"
fi
@danielsdeleo
danielsdeleo / gist:3063064
Created July 6, 2012 22:17
Knife Role Tree example output
ddeleo@boltzmann chef git:(master)> bin/knife role tree $node_name
top level
|-role[preprod]
| |-recipe[network]
| |-recipe[splunk42]
|-role[mysql-master]
| |-role[base]
| | |-role[platform-annoyances]
| | | |-recipe[platform-specific]
| | | |-recipe[selinux::disabled]
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@juanje
juanje / gist:3797297
Created September 28, 2012 00:38
Mount apt cache of a Vagrant box in the host to spin up the packages installation

This is a little trick I use to spin up the packages instalation on Debian/Ubuntu boxes in Vagrant.

I add a simple function that checks if a directory named something similar to ~/.vagrant.d/cache/apt/opscode-ubuntu-12.04/partial (it may have another path in Windows or MacOS) and create the directory if it doesn't already exist.

def local_cache(basebox_name)
  cache_dir = Vagrant::Environment.new.home_path.join('cache', 'apt', basebox_name)
  partial_dir = cache_dir.join('partial')
  partial_dir.mkdir unless partial_dir.exist?
 cache_dir
@btm
btm / load_expanded_node.rb
Created September 28, 2012 01:24
script for loading a node from json, expanding the run list and saving.
#!/usr/bin/env ruby
# Copyright 2012 Opscode <legal@opscode.com>
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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