Skip to content

Instantly share code, notes, and snippets.

@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']
@coderanger
coderanger / Rakefile
Created May 27, 2012 23:58
Invoke Librarian from Rake automatically
desc "Run librarian"
task :librarian do
puts "** Syncing with Cheffile"
system("librarian-chef install")
end
# Extend the existing task to also call librarian
task :update do
Rake::Task[:librarian].invoke
end
@coderanger
coderanger / default.rb
Created April 24, 2012 20:09
Chef resource alias
class Chef
class Recipe
def new_name(*args, &block)
method_missing(:old_name, *args, &block)
end
end
end
@coderanger
coderanger / ungemnasium.rb
Created April 10, 2012 07:02
Clean up after Gemnasium
require 'octokit'
c = Octokit::Client.new(:login => "...", :password => "...")
conn = c.instance_exec{connection}
c.repos.each do |r|
puts "Trying to unsub #{r.name}"
begin
conn.get("/repos/#{c.login}/#{r.name}/hooks").body.each do |hook|
@coderanger
coderanger / chunked.rb
Created April 6, 2012 00:11
Transfer-Encoding:chunked for Faraday
class Chunked < FaradayMiddleware::ResponseMiddleware
define_parser { |body|
return if body.empty?
raw_body = body
decoded_body = []
until raw_body.empty?
chunk_len, raw_body = raw_body.split("\r\n", 2)
chunk_len = chunk_len.split(';',2).first.hex
break if chunk_len == 0
decoded_body << raw_body[0, chunk_len]
@coderanger
coderanger / _grid.scss
Created March 30, 2012 23:25
Local grid support for Susy
@import "susy";
$grid-info-stack: ();
@function _stack_push($list, $item) {
@return join($item, $list);
}
@function _stack_top($list) {
@return nth($list, 1);
@coderanger
coderanger / How-to-use
Created September 2, 2011 18:07
Debug bootstrap template
Install to ~/.chef/bootstrap/ubuntu10.04-gems-debug.erb and then add "-d ubuntu10.04-gems-debug" to the end of your bootstrap or server create command.
#
# This is the template file
#
<Port <%= @port %> >
# bla bla bla
</Port>
#
# The problem is I get several files; port_80.conf port_8080.conf, ... port_8888.conf
r = gem_package "amazon-ec2" do
version "0.9.17"
end
r.run_action(:install)
require 'rubygems'
Gem.clear_paths
require 'AWS'
ruby_block "register_with_elb" do
from django import forms
from django.core.exceptions import ValidationError
from commis.api.cookbook.models import CookbookRecipe
from commis.api.node.models import Node
from commis.api.role.models import Role
class MultipleChoiceAnyField(forms.MultipleChoiceField):
"""A MultipleChoiceField with no validation."""