Skip to content

Instantly share code, notes, and snippets.


Michael Grosser grosser

View GitHub Profile
grosser / gist:2166521
Created Mar 23, 2012
Interact with commandline processess via stdin
View gist:2166521
# capture commandline output and send responses if nothing was read
def interact(command, answers)
puts command
line = ""
write = false
PTY.spawn(command) do |output, input, pid|
loop do
rs, ws, =[output], [input])
grosser / gist:1609781
Created Jan 14, 2012
Transactional fixtures with capybara javascript tests
View gist:1609781
ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do
def current_connection_id
# Thread.current.object_id
grosser / gist:1608889
Created Jan 13, 2012
Using no transactions for js request specs (may not work, just a prototype I do not want to loose...)
View gist:1608889
# 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
alias_method_chain :run_in_transaction?, :js
grosser / gist:1597288
Created Jan 11, 2012
git autobisect because bisect is too complicated....
View gist:1597288
@command = ARGV.join(' ')
if system @command
raise "Everything is fine here..."
def sh(cmd)
puts cmd
IO.popen(cmd) do |pipe|
while str = pipe.gets
grosser /
Last active Jul 27, 2016 — forked from huned/
Using RailsAdmin without devise

Using rails_admin without devise

Add RailsAdmin to your Gemfile

do NOT add devise

gem "rails_admin", :git => "git://"


grosser / Rakefile
Created Oct 4, 2011
rake version:bump:patch in the age of bundler gemspecs
View Rakefile
# extracted from
rule /^version:bump:.*/ do |t|
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
index = ['major', 'minor','patch'].index(':').last)
file = 'lib/GEM_NAME/version.rb'
version_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 / resque_web.rb
Created Sep 13, 2011 — forked from skippy/resque_web.rb
Mountable resque-web for rails 3+ apps
View resque_web.rb
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 /
Created Sep 10, 2011
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 ;)

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 / push_and_merge_all.rb
Created Aug 5, 2011
Script to push and merge all branches
View push_and_merge_all.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'rake'
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
sh "git fetch origin" # get current branch info
current_branch = `git branch | grep '*'`.split.last
def sync(branch)
sh "git checkout #{branch}"