Skip to content

Instantly share code, notes, and snippets.

View johnbintz's full-sized avatar

John Bintz johnbintz

View GitHub Profile
@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: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 / 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']
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 / 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
@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 / 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 / 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 / active_admin_ckeditor_patch.css.scss
Last active December 16, 2015 00:19 — forked from SebAshton/active_admin_ckeditor_patch.css.scss
More complete and Sass-y fix for Ckeditor in Active Admin.
body.active_admin {
.cke {
display: inline-block;
table { width: auto; }
width: 78%;
}
.cke_button_label {
@johnbintz
johnbintz / hooks.rb
Created May 17, 2013 14:44
Autogenerate and autosort missing i18n translation keys for a Rails application while running Cucumber features
# Put this in features/support/hooks.rb and add i18n-missing_translations and i18n_yaml_sorter to your Gemfile
require 'i18n/missing_translations'
require 'i18n_yaml_sorter'
at_exit do
require 'yaml'
data = YAML.load_file('config/locales/en.yml')
data.deep_merge!(I18n.missing_translations)