Skip to content

Instantly share code, notes, and snippets.

View blasterpal's full-sized avatar

Hank Beaver blasterpal

View GitHub Profile
@blasterpal
blasterpal / netstat_haus.sh
Created June 3, 2015 22:13
THE netstat command
netstat -nputw
@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 / 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 / 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 / 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 / shellshock_metasploit_example.sh
Last active February 17, 2018 19:36
shellshock metasploit example use
# setup metasploit from master on github: https://github.com/rapid7/metasploit-framework/wiki/Setting-Up-a-Metasploit-Development-Environment
# good help on console and metasploit: http://www.offensive-security.com/metasploit-unleashed/Msfconsole
#start msfconsole
use auxiliary/scanner/http/apache_mod_cgi_bash_env
set VHOST app.local
set TARGETURI "/all"
set RPORT 3000
@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 / 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 / find_replace_with_sed.sh
Created January 9, 2014 19:09
find and replace with sed using find
for FILE in `find . -type f -name *.rb`; do
sed -i '' 's/old-method/new_method/g' $FILE
done
@blasterpal
blasterpal / restore_ey_pg_dump.sh
Last active December 28, 2015 08:49
restore_ey_pg_dump
pg_restore -d app_dev -O -U hankbeaver --role=hankbeaver ~/Downloads/app.2013-11-14T01-20-03.dump