Skip to content

Instantly share code, notes, and snippets.

View grosser's full-sized avatar
🎯
Focusing

Michael Grosser grosser

🎯
Focusing
View GitHub Profile
@grosser
grosser / rake_autocomplete.rb
Created August 19, 2012 15:50 — forked from cayblood/rake_autocomplete.rb
Bash autocomplete script for rakefiles
#!/usr/bin/env ruby
# Complete rake tasks script for bash
# Save it somewhere and then add
# complete -C path/to/script -o default rake
# to your ~/.bashrc
# Xavier Shay (http://rhnh.net), combining work from
# Francis Hwang ( http://fhwang.net/ ) - http://fhwang.net/rb/rake-complete.rb
# Nicholas Seckar <nseckar@gmail.com> - http://www.webtypes.com/2006/03/31/rake-completion-script-that-handles-namespaces
# Saimon Moore <saimon@webtypes.com>
@grosser
grosser / Reporting.txt
Created May 11, 2012 20:21 — forked from webmat/benchmark.rb
Benchmark Your Bundle
gem install pru
bundle exec ruby benchmark.rb > report
cat report | pru 'split(/\s+/)' 'reject{|a| a.size != 6 }.map{|a| [a[0], a[1]] }.sort_by(&:last).reverse.map{|a| "#{a[0].ljust(21)} -> #{a[1]}" }.join("\n")' | head -n20
haml -> 0.320000
prawn -> 0.270000
mail -> 0.240000
webrat -> 0.230000
newrelic_rpm -> 0.210000
@grosser
grosser / rails_admin_without_devise.md
Last active July 27, 2016 06:25 — forked from huned/rails_admin_without_devise.md
Using RailsAdmin without devise

Using rails_admin without devise

Add RailsAdmin to your Gemfile

do NOT add devise

gem "rails_admin", :git => "git://github.com/sferik/rails_admin.git"

Bundle

@grosser
grosser / resque_web.rb
Created September 13, 2011 15:08 — forked from skippy/resque_web.rb
Mountable resque-web for rails 3+ apps
# https://gist.github.com/1214052
require 'sinatra/base'
class ResqueWeb < Sinatra::Base
require 'resque/server'
use Rack::ShowExceptions
if CFG[:user].present? and CFG[:password].present?
Resque::Server.use Rack::Auth::Basic do |user, password|
user == CFG[:user] && password == CFG[:password]
@grosser
grosser / gist:1168961
Created August 24, 2011 19:30 — forked from zeke/gist:20844
# drop this in a ruby file in my_rails_app/config/initializers
# restart your rails and app you're good to go!
class String
# remove middle from strings exceeding max length.
def ellipsize(options={})
max = options[:max] || 40
delimiter = options[:delimiter] || "..."
return self if self.size <= max
remainder = max - delimiter.size
@grosser
grosser / generic_job.rb
Created April 28, 2011 05:37 — forked from scottwater/mail_queue.rb
Deliver mails delayed XXXMailer.delayed_foo(user, bar)
class ResqueGenericJob
def self.perform(options={})
options = options.with_indifferent_access
klass = options[:class]
method = options[:method]
if options.has_key?(:args)
klass.constantize.send(method, *options[:args])
else
klass.constantize.send(method)
end
Rails::Initializer.run do |config|
#.......
config.middleware.use 'ResqueWeb'
end
@grosser
grosser / 1.jpg
Created September 6, 2010 19:31 — forked from anonymous/index.html
1.jpg
# Tag.find_values(:select => :user_id, :limit => 30) --> ["1", "3", "6"]
# Tag.find_values(:select => 'user_id, foobar', :limit => 30, :all=>true) --> [["1","A"], ["3","B"], ["6","C"]]
class ActiveRecord::Base
def self.find_values(options)
sql = self.send(:construct_finder_sql, options.except(:all))
result = connection.select_rows(sql, name)
if options[:all]
result
else
result.map{|v| v[0] }

Ever wondered how much who adds/removes, its time to find out :D (those are real stats, i just obfuscated the names )

###Results

Git scores (in LOC):
mr-add              :  +482273       -9466
justu               :  +286250       -159905
grosser             :  +152384       -323344

another : +121257 -82116