Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
def new_time(timestamp, options)
Time.new(
options[:year] || timestamp.year,
options[:month] || timestamp.month,
options[:day] || timestamp.day,
options[:hour] || timestamp.hour,
options[:min] || (opt
# Assumes /home/me/myapp is a virtualenv...
script "Install Requirements" do
interpreter "bash"
user "me"
group "me"
code <<-EOC
/home/me/myapp/bin/pip install -r /home/me/myapp/requirements.txt
EOC
not_if "/home/me/myapp/bin/pip freeze | grep 'an_dependency' > /dev/null"
@benjaminws
benjaminws / lpthw_ex_17.py
Last active December 10, 2015 20:39
My son wanted to know how to do LPTHW ex17 in one line...
import sys; open(sys.argv[2], 'w').write(open(sys.argv[1]).read())
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