Skip to content

Instantly share code, notes, and snippets.

View blasterpal's full-sized avatar

Hank Beaver blasterpal

View GitHub Profile
@blasterpal
blasterpal / ey_stack_upgrade_hist.sh
Created May 9, 2013 18:48
History of stack upgrades on EY Cloud
grep chef-ey /var/log/enzyme.log
@blasterpal
blasterpal / authorized_keys_test
Created April 27, 2013 00:11
authorized_keys_test
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvSV1BqFmaud/SDlZOaoWOZd1HXNLq7e9UfECDDtTP9Q3h0WTYAB9CB/0sprr/EwO2Hl4Uuqs3Ca4y/eFHXg7jF+MZuLAB2E3Vp90amUtP/gD/XEa8+OmzPl6QIl6/CW2tv2KTXh1fS/X8ITzQcwb/BB/XYdvwPdENt1PRaiZYKYM4t12Ir4QLGKMRaV6jasPKOND9uErxEZlOzMogU1ktMIq6cTdYJCY0MFk8sHpT0/+o3+0eha/YuWIq9NB9GL9sbqYtxHQT2O01dRSM1v+OT+j482QN76qsh1Ue++C2IRWgKyK+ikQAnPHNup6hcmwy46P1Z0Fcxkx91DdZlMhB hankbeaver@Hanks-MacBook-Pro.local
@blasterpal
blasterpal / stdin_prompt.rb
Created April 24, 2013 13:30
prompt for input ruby
def prompt(*args)
print(*args)
STDIN.gets.strip
end
# inspired from somewhere on stackoverflow. if that's all you need, then no need for a whole library.
@blasterpal
blasterpal / eb-config-pretty-print.sh
Created April 5, 2013 19:09
Fetch Elastic Beanstalk Config and pretty print
# uses underscore-cli Node project
# https://github.com/ddopson/underscore-cli
elastic-beanstalk-describe-configuration-settings -a <MY APP> -e <MY ENV> -j | underscore print > app-env-config.json
@blasterpal
blasterpal / grab_activerecord_adapter.sh
Created March 13, 2013 19:41
Want to know what ORM Adapter a Rails project is using from shell in a hurry without any yaml parsing?
AR_ADAPTER=`bundle exec rails runner 'puts "#{ActiveRecord::Base.connection.instance_variable_get(:@config)[:adapter]}"'`
@blasterpal
blasterpal / clean_redis_lists.rb
Created March 13, 2013 15:07
clear out some Redis keys/lists
require 'redis'
# cleanup is a breeze!
redis = Redis.new(:host => "localhost", :port => 6379)
resque_junk = redis.keys 'resque*'
resque_junk.each {|ea| redis.del ea}
@blasterpal
blasterpal / sorted_by_id.rb
Created March 5, 2013 12:30
Add default_scope to sort by :id for MySQL -> PostgreSQL migration, working version Rails 3.1.x
# Add to initializer
module SortedById
extend ActiveSupport::Concern
included do
default_scope order('id ASC')
end
end
Rails.application.eager_load!
models = ActiveRecord::Base.subclasses.collect {|ea| ea.name}
@blasterpal
blasterpal / sorted_by_id.rb
Last active December 14, 2015 12:19
default_scope for MySQL to PostgreSQL project migration. The id sort order is not == when compared to MySQL and many specs are failing, even some relating to Gem models.
# Needed because I also have Gem models that are throwing errors not just my models. I'd like to have one simple mixin or monkey patch.
# without mucking with ActiveRecord::Base too much.
module SortedById
extend ActiveSupport::Concern
included do
default_scope order('id ASC')
end
end
ActiveRecord::Base.send(:include,SortedById)
@blasterpal
blasterpal / upload_file_to_s3.rb
Last active December 14, 2015 07:38
upload file to s3
#use like
#AWS_KEY='asdasd' AWS_SECRET='123123' irb/script
source_file= 'nightly_s3_db.tar-ab'
target_subdir= 'ey-production-db-backups'
file_to_upload = File.basename(source_file)
bucket = 'co-devops'
key= "#{target_subdir}/#{file_to_upload}"
require 'fog'
@blasterpal
blasterpal / validate_bundler_cache.sh
Last active December 12, 2015 00:28
Validate your bundler cache for OSX. For use in your Ruby (or Rails) project that is managed with Bundler.
#!/usr/bin/env bash
if [[ $1 != [yY] ]] ; then
echo 'Ensure this is executed in your bundled project.'
echo 'i.e. where the Gemfile is located'
ehco 'you should run 'bundle clean' first to ensure you don't check unused gems
echo "Type 'Y/y' to proceed"
read proceed