Skip to content

Instantly share code, notes, and snippets.

View josephbridgwaterrowe's full-sized avatar

Joseph Bridgwater-Rowe josephbridgwaterrowe

  • Tulare, CA
  • 19:01 (UTC -07:00)
View GitHub Profile
@josephbridgwaterrowe
josephbridgwaterrowe / airbrake.rb
Last active August 29, 2015 14:09
Airbrake configuration from Figaro.
# /config/initializers/airbrake.rb
Airbrake.configure do |config|
config.api_key = Figaro.env.airbrake_api_key
config.host = Figaro.env.airbrake_host
config.port = 80
config.secure = config.port == 443
end
@josephbridgwaterrowe
josephbridgwaterrowe / string_extensions.rb
Created December 21, 2014 22:08
String refinements
module StringExtensions
refine String do
# "Brute force" underscore the string.
# Removes any non-alpha characters for clean symbol ready strings.
def brute_underscore
self.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
gsub(/([\\][\"])/,'').
tr('-', '_').
@josephbridgwaterrowe
josephbridgwaterrowe / deploy.example.rb
Last active August 29, 2015 14:19
Sample deploy file
lock '3.3.5'
set :application, 'app'
set :repo_url, ''
set :branch, 'master'
set :user, 'deploy'
set :deploy_to, '/var/www/app'
@josephbridgwaterrowe
josephbridgwaterrowe / gist:d5efab66e8405853024a
Last active August 29, 2015 14:26
jRuby environment vars
export JAVA_HOME=`/usr/libexec/java_home -v '1.8'`
export JAVA_PATH=`which java`
export JAVACMD=`which java`
@josephbridgwaterrowe
josephbridgwaterrowe / promisuous_subscriber
Last active July 28, 2017 14:47
Promiscuous Subscriber init.d
### BEGIN INIT INFO
# Provides: promiscuous subscribe
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Execute the promiscuous subscriber
# Description: Execute the promiscuous subscriber
### END INIT INFO
set -e
# Feel free to change any of the following variables for your app:
@josephbridgwaterrowe
josephbridgwaterrowe / interface_factory.rb
Last active September 17, 2015 17:47
Diplomat Classes WIP
# /app/models/interface/interface_factory.rb
module Interface
class InterfaceFactory
class << self
def build(context)
new(context).build
end
end
def initialize(context)
@josephbridgwaterrowe
josephbridgwaterrowe / my_form_object.rb
Created January 12, 2016 19:01
Form entry uniqueness validation and test
# /app/form_objects/my_form_object.rb
class MyFormEntry < FormEntry
attribute :reference, String
validate :unique_reference
def unique_reference
errors.add(:reference, "must be unique") if \
MyObject.find_by(reference: self.reference)
end
@josephbridgwaterrowe
josephbridgwaterrowe / _create.html.erb
Created March 19, 2016 19:43
twitter bootstrap popup modals with Rails JS ERB (ActiveRecord Model)
<% html = render partial: 'partial_to_render',
locals: { my_model: my_model } %>
$.unblockUI();
$('.modal').modal('hide');
$('#my-element').html('<%=j html %>');
$.jGrowl('<%= t(message) %>', { theme: 'alert-success' });
@josephbridgwaterrowe
josephbridgwaterrowe / .hound-rubocop.yml
Created March 31, 2016 22:17
Hound / Rubocop configuration
AllCops:
Exclude:
- "vendor/**/*"
- "db/schema.rb"
UseCache: false
Style/CollectionMethods:
Description: Preferred collection methods.
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
Enabled: true
PreferredMethods:

Keybase proof

I hereby claim:

  • I am josephbridgwaterrowe on github.
  • I am freakyjoe (https://keybase.io/freakyjoe) on keybase.
  • I have a public key whose fingerprint is A6F7 B2FF 058A EFA7 2FA0 11A5 AA45 1268 478B 9CFA

To claim this, I am signing this object: