Skip to content

Instantly share code, notes, and snippets.

Scott W. Bradley scottwb

View GitHub Profile
@scottwb
scottwb / pear.rb.diff
Created Jan 29, 2014
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! :)
View pear.rb.diff
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 Jan 29, 2014
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.
View mysql_cookbook.diff
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 Apr 19, 2014
Workaround for Haml issue #645
View haml_monkey_patch.rb
# 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 Apr 13, 2015
Wrapper script for Emacs.app
View emacs.sh
#!/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 Nov 30, 2009
Ruby Config Hierarchy Class
View config_hierarchy_classes.rb
#!/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 Dec 1, 2009
Ruby script to drop all tables in a MySQL database.
View drop_all_tables.rb
#!/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 Dec 1, 2009
String replacement in a string var in bash.
View bash_string_var_replacement.sh
#!/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 Dec 1, 2009
Script to kill Rails script/server processes.
View kill_server.rb
#!/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 Dec 1, 2009
Find a string in configured set of dirs and files.
View findstr.rb
#!/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 Dec 23, 2009
Create .pem certificate.
View makepem.sh
#!/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
You can’t perform that action at this time.