Skip to content

Instantly share code, notes, and snippets.

@stevehodgkiss
stevehodgkiss / add_bucket_tags.sh
Created April 14, 2022 06:47
Add s3 bucket tags with aws-cli, bash & jq
#!/bin/bash
additional_tag_set='[{"Key": "my-tag", "Value": "true"}]'
declare -a buckets=(
a-bucket
another-bucket
)
for bucket in "${buckets[@]}"; do
@stevehodgkiss
stevehodgkiss / sm-fzf-function.zsh
Last active November 20, 2020 02:07
stack master fzf helper
stackmaster-stacks() {
ruby -ryaml -e 'YAML.load(File.read("stack_master.yml"))["stacks"].each { |region, stacks| stacks.each { |s, _| puts "#{region} #{s}" } }'
}
stackmaster-default-account() {
ruby -ryaml -e 'puts Array(YAML.load(File.read("stack_master.yml")).dig("stack_defaults", "allowed_accounts")).first'
}
awsvault-accounts() {
cat ~/.aws/config | \
@stevehodgkiss
stevehodgkiss / display_json_secrets.rb
Created November 7, 2018 03:26
Displays Heroku config vars as JSON, to make importing them into EJSON files easier
require 'json'
require 'optparse'
options = {}
ARGV << '--help' if ARGV.empty?
OptionParser.new do |opts|
opts.on('--heroku-app HEROKU_APP', String, 'Heroku app name') do |o|
options[:heroku_app] = o
end

Keybase proof

I hereby claim:

  • I am stevehodgkiss on github.
  • I am stevehodgkiss (https://keybase.io/stevehodgkiss) on keybase.
  • I have a public key ASAA2U8Q8ebhM3kraRu5wWngRfUfs66XfQFjhw-6DHBsHQo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am stevehodgkiss on github.
  • I am stevehodgkiss (https://keybase.io/stevehodgkiss) on keybase.
  • I have a public key whose fingerprint is B0FA A300 34D9 5F38 1624 2EB2 32C6 AE7D C0F9 4BEF

To claim this, I am signing this object:

password
123456
12345678
1234
qwerty
12345
dragon
pussy
baseball
football
require 'redis'
require 'timeout'
redis = Redis.new
redis.set('chunky', 'bacon')
res_a = nil
res_b = nil
count = 0
outer_count = 0
# Patches Rails signed cookie jar to allow an old secret to be
# transitioned (read). Rails will re-generate the session
# cookie with the new secret for the response.
#
# https://github.com/rails/rails/blob/v3.2.18/actionpack/lib/action_dispatch/middleware/cookies.rb#L279-L332
#
# An alternative with no monkey patching - https://github.com/envato/rails_session_key_rotator
fail "This patch will need updating if it is to be used with Rails 4" if Rails.version[0] != '3'
@stevehodgkiss
stevehodgkiss / minitest_contexts.rb
Created August 4, 2014 23:06
context blocks for minitest
require 'minitest/autorun'
class MiniTest::Spec
class << self
alias context describe
end
end
describe Class do
context 'my context' do
# encoding: utf-8
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql2',
:host => '127.0.0.1',
:port => 13306,
:username => 'root',
:database => 'encoding_test',
:encoding => 'latin1')