Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
from base import BaseImmutable
class ImmutableModel(BaseImmutable):
def __init__(self, django_model):
temp_dict = {}
for field in django_model._meta.fields:
temp_dict[field.name] = getattr(django_model,field.name)
self.__dict__ = temp_dict
[2012-11-13T21:36:23+00:00] WARN: ruby_build cookbook is missing. Please add to the run_list (Action will be skipped).
@benjaminws
benjaminws / aws_play.go
Created October 6, 2012 21:08
playing with aws/goroutines
// Attempt at provisioning aws instances via goroutines/channels
// Start playing with porting microarmy
package main
import (
"launchpad.net/goamz/aws"
"launchpad.net/goamz/ec2"
)
// Probably wasn't necessary to extract this, but hey
@benjaminws
benjaminws / librarian-puppet.diff
Created October 3, 2012 19:32
extra forge section?
Cannot bounce Puppetfile.lock! Here's a diff:
FORGE
remote: http://forge.puppetlabs.com
specs:
puppetlabs/apt (0.0.4)
puppetlabs/stdlib (>= 2.2.1)
puppetlabs/stdlib (3.0.1)
puppetlabs/xinetd (1.1.0)
ripienaar/concat (0.2.0)
@benjaminws
benjaminws / backtrace.txt
Created September 7, 2012 18:51
Chef 10.14 Windows Server 2003 R2
Generated at 2012-09-07 14:48:51 -0400
TypeError: can't convert nil into String
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_inspectors/compile_error_inspector.rb:72:in `readlines'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_inspectors/compile_error_inspector.rb:72:in `file_lines'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_inspectors/compile_error_inspector.rb:67:in `display_upper_bound'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_inspectors/compile_error_inspector.rb:51:in `context'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_inspectors/compile_error_inspector.rb:44:in `add_explanation'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatters/error_mapper.rb:80:in `file_load_failed'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.14.0/lib/chef/formatte
@benjaminws
benjaminws / a_resource_loading_twice.md
Created August 2, 2012 17:51
resource running twice...

Take a look at the gist below for the code in question. Essentially it is taking a hash of packages with name and version key/value pairs, then iterating over them to populate the chef_gem resource.

We just discovered that this code is being run twice when executing chef-client on the node. After a bit of digging in the anatomy of a chef run wiki page, we discovered the following snippet that explained why this is happening.

http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run

Here:

Load Recipes >

@benjaminws
benjaminws / gist:2304910
Created April 4, 2012 19:24
current_status
remote: kiln: successfully pushed 3 changesets
abort: HTTP Error 500: Internal Server Error
@benjaminws
benjaminws / faster.sh
Created March 3, 2012 16:51
faster/slower tests for models
bsmith@bsmith-laptop!1264
-> time rspec -fd spec/models
Planet
Age
records the year of its birth
knows it's age
Size
has a size of 100 when width and height are 10
@benjaminws
benjaminws / vi
Created February 1, 2012 00:02
vi
-> /usr/bin/vi --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 6 2011 10:36:56)
@benjaminws
benjaminws / bounce_shoes.rb
Created January 22, 2012 21:24
Learning ruby with shoes!
# KBounce clone
# Setup a basic canvas, 600x400, not resizable
Shoes.app :width => 600, :height => 400, :resizable => false do
background black
# Put our vertical and horizontal baracades in a list
@linesv = []
@linesh = []