Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View blasterpal's full-sized avatar

Hank Beaver blasterpal

View GitHub Profile
#in environment.rb refer to this file BEFORE Initializer block or load in a file via require
# then use in code like this MyOracle.city_mapping_table
module MyOracle
module Configuration
def oracle
MyOracle
end
end
module Varnish
require 'net/telnet'
#requires telnet access from deploy machine
def global_purge(varnish_host,varnish_port)
#It WILL timeout, just accept it. Varnish does not have a command prompt.
result = run_varnish_cmd(varnish_host,varnish_port,'url.purge .*',3)
if result.include?("200")
return [true,"Varnish purged OK."]
else
curl -s -o "/dev/null" -w "\n\nSTATS:\n\ttime_total\t%{time_total}\n\ttime_namelookup\t%{time_namelookup}\n\ttime_connect\t%{time_connect}\n\ttime_appconnect\t%{time_appconnect}\n\ttime_pretransfer\t%{time_pretransfer}\n\ttime_starttransfer\t%{time_starttransfer}\n\tspeed_download\t%{speed_download}\n\tnum_connects\t%{num_connects}\n" "<url>"
x=1; while [ $x -le 10 ]; do RAILS_ENV=benchmark rake test:benchmark;x=$(( $x + 1 )); done
find . -type f -mtime 0 | egrep -v '.*(git|coverage|metric).*'
releases = for-each-ref --sort=taggerdate --format='%(refname:short)' refs/tags
def initialize(options = {})
options.each do |key, value|
send("#{key}=", value) if respond_to?(key)
end
end
@blasterpal
blasterpal / rails_custom_config.rb
Created November 16, 2010 16:01
Rails Custom Config
module MaxMedia
module Configuration
def ldap
MaxMedia
end
end
class << self
attr_accessor :server, :port, :query, :content_group, :approval_group, :publish_group, :bind_user, :password, :user_base
end
@blasterpal
blasterpal / test_email.rb
Created November 17, 2010 15:36
Plain SMTP Email-Relay Test script
require 'net/smtp'
message = <<MESSAGE_END
From: Hank Beaver <hbeaver@maxmedia.com>
To: Hank Beaver <hbeaver@gmail.com>
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
@blasterpal
blasterpal / clean_mongo_map_reduce.sh
Created December 20, 2010 13:40
Clean Mongo Tmp Mapreduce
mongo --eval "db.getCollectionNames().forEach(function(name){if(name.match(/^tmp/)){db[name].drop()}})" cms