Skip to content

Instantly share code, notes, and snippets.

Tim Diggins timdiggins

Block or report user

Report or block timdiggins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ruby crashreport
Process: ruby [1079]
Path: /usr/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: zsh [327]
Date/Time: 2009-05-13 14:26:58.435 +0100
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
View crash report with nokogiri 1.2.4
Process: ruby [4332]
Path: /usr/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: zsh [327]
Date/Time: 2009-05-15 11:15:29.213 +0100
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6
timdiggins / chef-roles-to-json-task.rb
Created Feb 19, 2011
rake task to convert existing ruby roles to json
View chef-roles-to-json-task.rb
# ADD this to Rakefile and run it by issuing rake roles.to_json
ROLE_DIR = File.expand_path(File.join(TOPDIR, "roles"))
namespace :roles do
desc "Convert ruby roles from ruby to json, creating/overwriting json files."
task :to_json do
Dir.glob(File.join(ROLE_DIR, '*.rb')) do |rb_file|
role =
json_file = rb_file.sub(/\.rb$/,'.json')
timdiggins / search_for_chef_solo.rb
Created Mar 8, 2011
simplistic search implementation for chef solo
View search_for_chef_solo.rb
# better to use a monkeypatch - see
timdiggins / Vagrant_monkeypatch.rb
Created Mar 13, 2011
Vagrantfile monkeypatch of Vagrant's chef solo provisioner to allow databag folders
View Vagrant_monkeypatch.rb
CHEF_REPO = "../chef_repo" # path to chef repo,
# because Vagrantfile is normally in application repo, not in chef repo.
# see also for chef_solo patch
module Vagrant
module Provisioners
class ChefSolo
class Config
attr_accessor :data_bag_path
timdiggins / chef_solo_patch.rb
Created Mar 13, 2011
Monkeypatch for chef solo to do basic data_bag manipulations
View chef_solo_patch.rb
# save this in the library folder of a cookbook
# (e.g. ./coookbooks/vagrant/library/chef_solo_patch.rb)
# see also for vagrant patch
# based on
if Chef::Config[:solo]
class Chef
module Mixin
module Language
def data_bag(bag)
View gist:901829
/usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:95:in `raw_data=': Data Bag Items must have an id key in the hash! {"evq"=>""} (Chef::Exceptions::ValidationFailed)
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:147:in `from_hash'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/data_bag_item.rb:183:in `load'
from /var/chef/cache/cookbooks/django/libraries/app.rb:6:in `initialize'
from /var/chef/cache/cookbooks/django/definitions/install.rb:3:in `new'
from /var/chef/cache/cookbooks/django/definitions/install.rb:3:in `from_file'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/chef-0.9.14/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:50:in `method_missing'
from /var/chef/cache/cookbooks/django/definitions/install.rb:42:in `from_file'
from /usr/lib/ruby/gems/1.8/gems/chef
timdiggins / attr_test_css.rb
Created May 26, 2012
Quick demo of problem with css attribute search with slash
View attr_test_css.rb
require 'test/unit'
require 'nokogiri'
class AttributeWithSlashCssTest < Test::Unit::TestCase
def setup
@doc = Nokogiri.parse(
<a href=\"/my/path\">My link text</a>
<a href=\"/my-other-path\">
timdiggins / gist:2899995
Created Jun 9, 2012
method to extract parts from a rails Mail::Message
View gist:2899995
def parts(email)
splits = email.encoded.split(/(\r\n)*----==_mimepart_[a-zA-Z0-9_]+(\r\n)*/)
parts = {header: splits[0]}
splits[1..-2].each do |part|
headers, body = part.split(/\r\n\r\n/, 2)
if(m = /Content-Type: ([^; ]+);?\s/.match(headers))
type = m[1]
parts[type] =, body:body)
timdiggins / traceback.txt
Created Jan 24, 2013
traceback for stack overflow problem
View traceback.txt
ActionView::Template::Error: undefined method `action_methods' for nil:NilClass
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/authlogic-3.2.0/lib/authlogic/controller_adapters/abstract_adapter.rb:63:in `method_missing'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/activeadmin-0.5.1/lib/active_admin/resource/action_items.rb:56:in `block in add_default_action_items'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/activeadmin-0.5.1/lib/active_admin/views/action_items.rb:9:in `instance_eval'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/activeadmin-0.5.1/lib/active_admin/views/action_items.rb:9:in `block (2 levels) in build'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/arbre-1.0.1/lib/arbre/context.rb:92:in `with_current_arbre_element'
/Users/tim/.rvm/gems/ruby-1.9.2-p320@buddy/gems/arbre-1.0.1/lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
You can’t perform that action at this time.