Skip to content

Instantly share code, notes, and snippets.

View blasterpal's full-sized avatar

Hank Beaver blasterpal

View GitHub Profile
@blasterpal
blasterpal / campfire-pid-watcher.rb
Created April 3, 2014 13:21
campfire-pid-watcher - need to gemify later...
require 'tinder'
pid = 2461
message = "DB restore complete!"
campfire = Tinder::Campfire.new 'subdomain', :token =>'zxzxc'
room = campfire.find_room_by_name 'roomname'
puts "watching and waiting for pid #{pid} to complete"
while `ps --no-headers #{pid}`.size > 0
puts "pid lives, waiting"
sleep 10
@blasterpal
blasterpal / deploy_tag_heroku.sh
Created May 13, 2014 13:04
Deploy tag to Heroku
git push -f staging v1.3^{}:master
@blasterpal
blasterpal / like_before_filter.rb
Created October 7, 2014 13:43
A simple before_filter-ish functionality
#pry -r ./rate_limit_test.rb
require './using_rate_limits'
require './rate_limitable'
f = UsingRateLimits.new
require'pry';binding.pry
f.some_method
#using_rate_limits.rb
require './rate_limitable'
class UsingRateLimits
@blasterpal
blasterpal / bugsnag_query.rb
Last active August 29, 2015 14:14
querying bugsnag for data
# https://github.com/bugsnag/bugsnag-api-ruby
require 'bugsnag/api'
Bugsnag::Api.configure do |config|
config.auth_token = "your-account-api-token"
end
errors = Bugsnag::Api.errors(web_project_id)
error = Bugsnag::Api.error(error_id)
events = Bugsnag::Api.error_events error_id
@blasterpal
blasterpal / gist:578e59ce03d55cf3e55e
Last active August 29, 2015 14:18
Programmatically print Rails routes
Rails.application.routes.routes.each do |route|
puts route.path.spec.to_s
end;nil
# specs with stubbed routes: https://github.com/blakechambers/matterhorn/blob/master/spec/support/url_test_helpers.rb
routes.routes.each do |route|
puts route.path.spec.to_s
end;nil
Rails.application.routes.named_routes.helpers
@blasterpal
blasterpal / num_docs_solr.rb
Created May 20, 2015 18:14
Get total number of documents in Solr via Sunspot/RSolr
solr = RSolr.connect :url => solr_server #http://solr:8983/solr/some-index
response = solr.get 'select', :params => {
:q => '*:*',
:rows => 0
}
@blasterpal
blasterpal / netstat_haus.sh
Created June 3, 2015 22:13
THE netstat command
netstat -nputw
@blasterpal
blasterpal / add_docker_host_ip.sh
Created August 9, 2015 17:31
Adding DockerHost ip to container
$ alias hostip="ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"
$ docker run --add-host=docker:$(hostip) --rm -it debian
@blasterpal
blasterpal / create_rabbit_queue_and_such.bash
Created August 19, 2015 16:30
Create RabbitQ queue, exchange and bind to routing key w/ Curl.
# create queue
# /api/queues/vhost/name
curl -i -u $AMQP_USER:$AMQP_PASSWORD -H "content-type:application/json" \
-XPUT -d'{"auto_delete":false,"durable":true,"arguments":[]}' \
"http://$AMQP_HOST:$RABBIT_MGT_PORT/api/queues/%2F/$SCHEDULER_TRIGGER_QUEUE"
# create exchange
# PUT /api/exchanges/vhost/name
curl -i -u $AMQP_USER:$AMQP_PASSWORD -H "content-type:application/json" \
-XPUT -d'{"type":"direct","auto_delete":false,"durable":true,"arguments":[]}' \
@blasterpal
blasterpal / osx_find_replace_sed.ah
Created August 19, 2015 18:40
OSX find replace w/ Sed
find . -type f -name '*.rb' -exec sed -i '' 's/rfc3339(9)/rfc3339/g' \{\} \;