Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Michael Grosser grosser

🎯
Focusing
View GitHub Profile
@grosser
grosser / rake_autocomplete.rb
Created Aug 19, 2012 — forked from cayblood/rake_autocomplete.rb
Bash autocomplete script for rakefiles
View rake_autocomplete.rb
#!/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 — forked from webmat/benchmark.rb
Benchmark Your Bundle
View Reporting.txt
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 Jul 27, 2016 — forked from huned/rails_admin_without_devise.md
Using RailsAdmin without devise
View rails_admin_without_devise.md

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 Sep 13, 2011 — forked from skippy/resque_web.rb
Mountable resque-web for rails 3+ apps
View resque_web.rb
# 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]
View gist:1168961
# 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 Apr 28, 2011 — forked from scottwater/mail_queue.rb
Deliver mails delayed XXXMailer.delayed_foo(user, bar)
View generic_job.rb
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
View environment.rb
Rails::Initializer.run do |config|
#.......
config.middleware.use 'ResqueWeb'
end
View find_values.rb
# 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] }
View README.markdown

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