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 / keybase.md
Created October 27, 2015 18:46
keybase.md

Keybase proof

I hereby claim:

  • I am grosser on github.
  • I am grosser (https://keybase.io/grosser) on keybase.
  • I have a public key whose fingerprint is 4435 57FE 9ACF 3D5D 4244 CF05 772C BEFC F3BF D2E5

To claim this, I am signing this object:

`rm accounts/*`
ips = File.readlines('ips.txt')
accounts = File.readlines('accounts.txt')
mapping = {}
accounts.each_with_index.map do |subdomain, i|
ip = ips[i % ips.size].strip
mapping[ip] ||= []
mapping[ip] << subdomain.strip
Dir["tmp/*.txt"].each do |ip_file|
puts "-" * 50
puts ip_file
ip = File.basename(ip_file).sub('.txt','')
puts "ip #{ip}"
puts "result:"
puts `cat #{ip_file} | ruby script/patch_dns #{ip}`
raise unless $?.success?
end
@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 / gist:1608889
Created January 13, 2012 21:49
Using no transactions for js request specs (may not work, just a prototype I do not want to loose...)
# js-request tests cannot use transactions, since they happen in another process
# so if we are in js request tests, use the real test database and then clean it afterwards
module ActiveRecord
module TestFixtures
def run_in_transaction_with_js?
return false if $disable_transactions
run_in_transaction_without_js?
end
alias_method_chain :run_in_transaction?, :js
@grosser
grosser / gist:1597288
Created January 11, 2012 22:54
git autobisect because bisect is too complicated....
@command = ARGV.join(' ')
if system @command
raise "Everything is fine here..."
end
def sh(cmd)
puts cmd
IO.popen(cmd) do |pipe|
while str = pipe.gets
@grosser
grosser / Rakefile
Created October 4, 2011 12:03
rake version:bump:patch in the age of bundler gemspecs
# extracted from https://github.com/grosser/project_template
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(t.name.split(':').last)
file = 'lib/GEM_NAME/version.rb'
version_file = File.read(file)
old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
version_parts[index] = version_parts[index].to_i + 1
version_parts[2] = 0 if index < 2
@grosser
grosser / Readme.md
Created September 10, 2011 12:38
Most recommended games on Steam

Get the most recommended games from steam (because steam does not tell...) this is an example and no invitation to DDos steam ;)

@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