Skip to content

Instantly share code, notes, and snippets.

View grosser's full-sized avatar
🎯
Focusing

Michael Grosser grosser

🎯
Focusing
View GitHub Profile
# frozen_string_literal: true
source 'https://rubygems.org'
ruby "~> #{File.read('.ruby-version').strip}"
# bot
gem 'slack-ruby-bot'
gem 'slack-ruby-client'
gem 'async-websocket', '~> 0.8.0'
#!/bin/bash -e
# Kubernetes api server is supposed to run compaction on etcd
# when that does not happen we need to do an emergency compaction to make etcd not lock up
# this should only be done once, so we pick the leader to do it, which we assume is healthy
# (compacting manually outside of api server can lead to watches failing / requests for specific revisions failing etc)
#
# After compacting the keyspace, the backend database may exhibit internal fragmentation.
# Any internal fragmentation is space that is free to use by the backend but still consumes storage space.
# The process of defragmentation releases this storage space back to the file system.
@grosser
grosser / slow.rego
Created January 1, 2020 01:34
opa test is slow
package k8srequiredlabels
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.parameters.labels[_]}
missing := required - provided
count(missing) > 0
msg := sprintf("opa-gatekeeper: you must provide labels %v for %v %v/%v", [missing, input.review.object.kind, input.review.object.metadata.namespace, input.review.object.metadata.name])
}
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
@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)
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 / 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:

@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 / 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 / Gemfile
Created March 15, 2015 18:12
Rubymine ex with bundle
source "https://rubygems.org"
gem "parallel"