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 / unicorn_utils_sync_patch.rb
Created November 23, 2013 02:36
Make unicorn normally write to files even if they are not synced by @eac
# For Rails3, Rails.logger sync = false. Unicorn's log detection needs to accomodate this
module Unicorn
module Util
# :stopdoc:
def self.is_log?(fp)
append_flags = File::WRONLY | File::APPEND
! fp.closed? &&
fp.stat.file? &&
@grosser
grosser / mil_with_mail.rb
Created January 14, 2014 19:29
Making rails 2 use mail instead of tmail
module MailWithMail
# stolen + made static from Rails 3.0 action_mailer/old_api.rb
def self.set_content_type(m, user_content_type, class_default, params)
case
when user_content_type.present?
user_content_type
when m.has_attachments?
if m.attachments.detect { |a| a.inline? }
["multipart", "related", params]
else
@grosser
grosser / rails_2_hacks.rb
Created January 14, 2014 19:53
hacks that help getting a rails 2 app run like a rails 3 app
# test
if Rails::VERSION::MAJOR == 2
# make integration tests use rack response, so we can test our middlewares
# and not only the pure controller response
ActionController::Base.class_eval do
# this is usually done just-in-time by #process but we need to do it earlier
include ActionController::Integration::ControllerCapture
# then we hide last_instantiation from #process
@grosser
grosser / Gemfile
Created March 15, 2015 18:12
Rubymine ex with bundle
source "https://rubygems.org"
gem "parallel"
@grosser
grosser / Post.md
Last active August 29, 2015 14:20
Updating rails versions while keeping the business running

Updating rails versions on big apps can be dangerous and time consuming. This is the workflow we use to deploy and test our Rails upgrades in isolation, before releasing them to everybody and without blocking other changes.

Gemfile

ln -s Gemfile Gemfile.rails4 and use BUNDLE_GEMFILE=Gemfile.rails4 bundle exec rails c to run rails 4.

if ENV['BUNDLE_GEMFILE'].to_s.include?('rails4')
 gem "rails", "4.0.13"
@grosser
grosser / travis_failures.rb
Last active August 29, 2015 14:21
Analyze travis failures from forking_test_runner across all jobs in the build
#!/usr/bin/env ruby
#
# show travis build failures for given build id/url, branch or current branch
# streams logs and shows errors as they happen
#
def usage
puts <<-TEXT.gsub(/^ /, "")
Setup
-----
@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:

begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
gem "activerecord"
@grosser
grosser / build.rb
Last active April 16, 2018 22:35
Building single/partial steps from cloudbuild.yaml
remote = ARGV.delete("--remote")
id = ARGV.pop
abort "Usage: ruby build.rb <id|all> [--remote]" unless ARGV.empty?
unless system('which container-builder-local')
abort "Run: gcloud components install container-builder-local"
end
def dependencies(steps, id)
ruby test.rb internaltools.k8s.local
Warming up --------------------------------------
kubeclient os 1.000 i/100ms
kubeclient json 1.000 i/100ms
faraday json 1.000 i/100ms
faraday persistent 1.000 i/100ms
Calculating -------------------------------------
kubeclient os 1.896 (± 0.0%) i/s - 10.000 in 5.275373s
kubeclient json 1.907 (± 0.0%) i/s - 10.000 in 5.248037s
faraday json 1.933 (± 0.0%) i/s - 10.000 in 5.175768s