Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
@johnbintz
johnbintz / Guardfile
Created January 31, 2013 16:38
Make guard, guard-livereload, and a Rails server play nice in Foreman, so that you can see logs in the Foreman output and so Guard doesn't take over the input/output.
group :livereload do
guard 'livereload' do
watch(things)
end
end
@johnbintz
johnbintz / mongoid-accepts_embedded_resource_for.gemspec
Created October 22, 2012 21:07
Add accepts_embedded_resources_for to Mongoid::NestedAttributes
Gem::Specification.new do |s|
s.name = 'mongoid-accepts_embedded_resource_for'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'John Bintz'
s.email = '[email protected]'
s.summary = 'Add accepts_embedded_resources_for to Mongoid::NestedAttributes, so it plays nicer with Carrierwave and embedded documents'
s.description = 'Add accepts_embedded_resources_for to Mongoid::NestedAttributes, so it plays nicer with Carrierwave and embedded documents'
s.files = ['mongoid-accepts_embedded_resource_for.rb']
@johnbintz
johnbintz / draper-mongoid.gemspec
Created September 21, 2012 16:27
Ensure Mongoid documents work with Draper
Gem::Specification.new do |s|
s.name = 'draper-mongoid'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'John Bintz'
s.email = '[email protected]'
s.summary = 'Quick little hack to make Mongoid work with Draper wrt model_name'
s.description = 'Quick little hack to make Mongoid work with Draper wrt model_name'
s.files = ['draper-mongoid.rb']
@johnbintz
johnbintz / presenter.rb
Created September 21, 2012 14:45
Simple Presenter pattern in ~30 lines of code.
require 'delegate'
class Presenter < SimpleDelegator
def self.model_name
@_model_name ||= ActiveModel::Name.new(self.name.gsub('Presenter', '').constantize)
end
def self.for(objects)
objects.collect { |item| (item.class.name + "Presenter").constantize.new(item) }
end
Gem::Specification.new do |s|
s.name = 'add_t'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'John Bintz'
s.email = '[email protected]'
s.summary = 'Filter JavaScript files for %{path} and replace it with the logical Sprockets path.'
s.description = 'Filter JavaScript files for %{path} and replace it with the logical Sprockets path.'
s.files = ['add_t.rb']
@johnbintz
johnbintz / wait_for_port.gemspec
Created August 15, 2012 16:10
wait_for_port, a simple way to wait for a port to be open/closed
Gem::Specification.new do |s|
s.name = 'wait_for_port'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'John Bintz'
s.email = '[email protected]'
s.summary = 'Wait for a port to be open or not open.'
s.description = 'Wait for a port to be open or not open.'
s.files = ['wait_for_port.rb']
@johnbintz
johnbintz / gist:3165640
Created July 23, 2012 19:25
mysql homebrew install issue
# brew doctor
Your system is raring to brew.
# brew --config
HOMEBREW_VERSION: 0.9.2
HEAD: a320ba2b7aa2a19b5a0f81a03329af2d95b91130
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
@johnbintz
johnbintz / perf_and_gc.diff
Created June 21, 2012 12:49 — forked from funny-falcon/perf_and_gc.diff
Ruby-1.9.3-p194 performance patch
diff --git a/common.mk b/common.mk
index eb89a2b..59cdfe4 100644
--- a/common.mk
+++ b/common.mk
@@ -630,7 +630,8 @@ file.$(OBJEXT): {$(VPATH)}file.c $(RUBY_H_INCLUDES) {$(VPATH)}io.h \
gc.$(OBJEXT): {$(VPATH)}gc.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
{$(VPATH)}regex.h $(ENCODING_H_INCLUDES) $(VM_CORE_H_INCLUDES) \
{$(VPATH)}gc.h {$(VPATH)}io.h {$(VPATH)}eval_intern.h {$(VPATH)}util.h \
- {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h
+ {$(VPATH)}debug.h {$(VPATH)}internal.h {$(VPATH)}constant.h \
@johnbintz
johnbintz / gist:2965472
Last active October 6, 2015 08:28
ruby 1.9.3-p327 with performance patches built into a .deb package with fpm
# For Debian Squeeze + Backports + OpenSSL 1.0.0
# Part 1: Make a deb package of ruby:
# Get our deps
sudo su -c "echo deb http://backports.debian.org/debian-backports squeeze-backports main > /etc/apt/sources.list.d/squeeze-backports.list"
sudo apt-get update
sudo apt-get install -y python-setuptools python-dev build-essential dpkg-dev libopenssl-ruby ruby1.8-dev rubygems bison autoconf zlib1g zlib1g-dev libreadline6 libreadline6-dev libssl1.0.0 libssl-dev
# Get ruby
if [ ! -f ruby-1.9.3-p327.tar.gz ]; then
@johnbintz
johnbintz / flay.rb
Created April 20, 2012 19:14
Run flay on your Cucumber steps after a successful run
# run flay on your cucumber steps after a successful run. prevent bloat and
# promote reusability!
flay_exception = nil
flay_level = 32 # set me to a minimum sane level. don't go nuts refactoring!
# code should be cleaner when you're done, not become spaghetti.
After do |s|
flay_exception ||= s.exception
end