This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do | |
def current_connection_id | |
# Thread.current.object_id | |
Thread.main.object_id | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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, = IO.select([output], [input]) |
NewerOlder