Skip to content

Instantly share code, notes, and snippets.

View scottwb's full-sized avatar

Scott W. Bradley scottwb

View GitHub Profile
@scottwb
scottwb / pear.rb.diff
Created January 29, 2014 16:41
Illustrates bug (and fix) in the `php` community cookbook's `pear` provider from https://github.com/opscode-cookbooks/php/blob/master/providers/pear.rb that occurs when upgrading packages when there is not detectable version to upgrade to. Free for anyone with a CLA to take and contribute! :)
diff --git a/cookbooks/php/providers/pear.rb b/cookbooks/php/providers/pear.rb
index db90e17..0172fca 100644
--- a/cookbooks/php/providers/pear.rb
+++ b/cookbooks/php/providers/pear.rb
@@ -155,7 +155,8 @@ def upgrade_package(name, version)
command = "echo \"\r\" | #{@bin} -d"
command << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
command << " upgrade -a#{expand_options(@new_resource.options)}"
- command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}-#{version}"
+ command << " #{prefix_channel(can_haz(@new_resource, "channel"))}#{name}"
@scottwb
scottwb / mysql_cookbook.diff
Created January 29, 2014 22:09
The Chef Community MySQL cookbook does not allow a mysql server with no root password when using chef-solo. That's how I like it for easy test VMs, so I made these change to it. Consider this an obvious change. Take it as you please. YMMV.
diff --git a/cookbooks/mysql/libraries/helpers.rb b/cookbooks/mysql/libraries/he
index c850233..1a5d99c 100644
--- a/cookbooks/mysql/libraries/helpers.rb
+++ b/cookbooks/mysql/libraries/helpers.rb
@@ -30,15 +30,18 @@ module Opscode
end
def assign_root_password_cmd
+ return nil unless node['mysql']['server_root_password']
str = '/usr/bin/mysqladmin'
@scottwb
scottwb / haml_monkey_patch.rb
Created April 19, 2014 03:08
Workaround for Haml issue #645
# This is a workaround for the Haml bug:
#
# https://github.com/haml/haml/issues/645
#
module Haml
module Filters
class SassRailsTemplate
def render(scope=Object.new, locals={}, &block)
scope = ::Rails.application.assets.context_class.new(
"::Rails.application.assets",
@scottwb
scottwb / emacs.sh
Created April 13, 2015 14:37
Wrapper script for Emacs.app
#!/bin/sh
# Put somewhere in your $PATH and call the file `emacs`
/Applications/Emacs.app/Contents/MacOS/Emacs $1 $2 $3 1>&2 > /dev/null &
@scottwb
scottwb / config_hierarchy_classes.rb
Created November 30, 2009 00:49
Ruby Config Hierarchy Class
#!/usr/bin/env ruby
# This file demonstrates a simple experiment to make a hierarchy of config classes
# where each class can simply define a hash of config values which augment/override
# those of it's parent class. Each class uses class methods to access the config
# values by name. In addition to the config hash, each class can define custom
# class methods that combine/format config values, even if those values are actually
# defined in an ancestor or descendant class.
class BaseConfig
@scottwb
scottwb / drop_all_tables.rb
Created December 1, 2009 10:09
Ruby script to drop all tables in a MySQL database.
#!/usr/bin/env ruby
#
# Drops all the tables in a MySQL database, without dropping the databse.
#
###############################################################################
# Usage
###############################################################################
usage=<<EOT
@scottwb
scottwb / bash_string_var_replacement.sh
Created December 1, 2009 09:13
String replacement in a string var in bash.
#!/bin/sh
# Shows how to do replacment in a string variable in bash.
SRC_STRING=/Applications/something
REPLACED_STRING=${SRC_STRING//\//\\/}
echo "Source String is: $SRC_STRING"
echo "Replaced String is: $REPLACED_STRING"
@scottwb
scottwb / kill_server.rb
Created December 1, 2009 10:28
Script to kill Rails script/server processes.
#!/usr/bin/env ruby
#
# Quick-and-dirty script to kill rogue script/server processes.
#
###############################################################################
# Configuration
###############################################################################
# The command you use to run your Rails server.
@scottwb
scottwb / findstr.rb
Created December 1, 2009 11:45
Find a string in configured set of dirs and files.
#!/usr/bin/env ruby
#
# Script to search for a string in a set of configured dirs. The main
# value of this is to provide:
#
# * Easy configuration for a common set of directories you like to
# grep through, and the file patterns to match per directory.
#
# * Easy configuration for the common grep options you like to use.
#
@scottwb
scottwb / makepem.sh
Created December 23, 2009 11:01
Create .pem certificate.
#!/bin/sh
#
# Script to create an SSL .pem certificate.
#
# Adapted from Fedora's /etc/pki/tls/certs/Makefile. Only tested on
# Mac OS X 10.5.
#
PEMFILE=$1