Skip to content

Instantly share code, notes, and snippets.

Scott W. Bradley scottwb

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am scottwb on github.
  • I am scottwb (https://keybase.io/scottwb) on keybase.
  • I have a public key ASDC8tX5gl6bMMaEnHY4UeW1PDECJCiF7S2vqTuQLWSt7wo

To claim this, I am signing this object:

@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 / 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 / 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 / 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 / pear.rb.diff
Last active Jan 3, 2016
Illustrates bug (and fix) in the php::module_apc cookbook from https://github.com/opscode-cookbooks/php/blob/master/providers/pear.rb that occurs on centos.
View pear.rb.diff
diff --git a/cookbooks/php/providers/pear.rb b/cookbooks/php/providers/pear.rb
index ca473b5..db90e17 100644
--- a/cookbooks/php/providers/pear.rb
+++ b/cookbooks/php/providers/pear.rb
@@ -258,13 +258,13 @@ def pecl?
@pecl ||= begin
# search as a pear first since most 3rd party channels will report pears as pecls!
search_cmd = "#{node['php']['pear']} -d"
- search_cmd << " preferred_state=#{can_haz(@new_resource, preferred_state)}"
+ search_cmd << " preferred_state=#{can_haz(@new_resource, "preferred_state")}"
@scottwb
scottwb / idle.js
Last active Jan 2, 2016
A javascript function banks can use to determine if they should log out a user session for being idle.
View idle.js
function shouldLogOutIdleSession() {
return false;
}
View dynamic_ripple_finders.rb
# Don't you feel like doing something like this when you use Ripple?
# Obviously there's more to it than this mockup, but man this would
# be nice, wouldn't it?
module Ripple
class Document
def self.method_missing(method, args)
if method.to_s =~ /^find_by_(.*)$/
return find_by_index($1.to_sym, *args)
end
super
View bootstrap-windows.rb
#!/usr/bin/env/ruby
require 'socket'
# AWS API Credentials
AWS_ACCESS_KEY_ID = "your-aws-access-key-id"
AWS_SECRET_ACCESS_KEY = "your-aws-secret-access-key"
# Node details
NODE_NAME = "webserver-01.example.com"
View devise.rb
# Generate a token by looping and ensuring does not already exist.
def generate_token(column)
loop do
token = Devise.friendly_token
break token unless to_adapter.find_first({ column => token })
end
end
You can’t perform that action at this time.