Skip to content

Instantly share code, notes, and snippets.

View sfgeorge's full-sized avatar

Stephen George sfgeorge

View GitHub Profile
<?php
class A {
public $foo = null;
public function getFooClass() {
return get_class(); // null param means "What's *my* class?"
}
}
$a = new A();
<?php
class Foo {};
$a = new Foo;
var_dump($a instanceof stdClass); // returns FALSE
?>
@sfgeorge
sfgeorge / gist:1217501
Created September 14, 2011 19:18
Playing around with #ahn_log
@call.call.ahn_log 'Calling @call.call.ahn_log with a string'
@call.call.ahn_log { 'Calling @call.call.ahn_log with a block' } # This does not get logged
@call.call.ahn_log.http.info 'Calling @call.call.ahn_log.http.info with a string' # This does not log call context
@call.call.ahn_log.http.info { 'Calling @call.call.ahn_log.http.info with a block' } # This does not log call context
# Yields:
=begin
INFO sipserdevphp5b7d00498: Calling @call.call.ahn_log with a string
INFO http: Calling @call.call.ahn_log.http.info with a string
INFO http: Calling @call.call.ahn_log.http.info with a block
@sfgeorge
sfgeorge / gist:1237573
Created September 23, 2011 14:57
Problems using logging :formatter in daemon mode
/Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhearsion-1.2.1/lib/adhearsion/initializer/configuration.rb:72:in `logging': undefined method `count' for #<Log4r::FileOutputter:0x007
fbd31d2ec40> (NoMethodError)
from /Users/sgeorge/Code/ifbyphone/cloudvox/apptastic/config/adhearsion.rb:44:in `block in <top (required)>'
from /Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhearsion-1.2.1/lib/adhearsion/initializer/configuration.rb:28:in `configure'
from /Users/sgeorge/Code/ifbyphone/cloudvox/apptastic/config/adhearsion.rb:28:in `<top (required)>'
from /Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhearsion-1.2.1/lib/adhearsion/initializer.rb:272:in `load'
from /Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhearsion-1.2.1/lib/adhearsion/initializer.rb:272:in `block in load_all_init_files'
from /Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhearsion-1.2.1/lib/adhearsion/initializer.rb:272:in `each'
from /Users/sgeorge/.rvm/gems/ruby-1.9.2-p180/gems/adhears
@sfgeorge
sfgeorge / ca-bundle.crt
Created December 12, 2011 01:03
Example outdated root CA list file that fails to verify https://airbrake.io
# This is a bundle of X.509 certificates of public Certificate
# Authorities. It was generated from the Mozilla root CA list.
#
# Source: mozilla/security/nss/lib/ckfw/builtins/certdata.txt
#
# Generated from certdata.txt RCS revision 1.39
#
Certificate:
Data:
Version: 1 (0x0)
@sfgeorge
sfgeorge / gist:1464144
Created December 12, 2011 01:42
SSL rake error
# Step 1. Use a system with an outdated SSL CA file
# Step 2. Run the toadhopper integration rake tasks:
bundle exec rake test AIRBRAKE_API_KEY=$AIRBRAKE_API_KEY AIRBRAKE_FULL_TEST=1
# Output:
Loaded suite /usr/local/rvm/gems/ruby-1.9.2-p180/gems/rake-0.9.2.2/lib/rake/rake_test_loader
Started
...E
events.after_initialized.each do
puts "Knock, knock"
raise 'fury'
puts "Who's there?"
end
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
1 0 52 110832 149208 1530724 0 0 4 232 1593 3277 1 1 98 1 0
0 0 52 111328 149208 1530728 0 0 0 0 1470 3213 0 0 99 0 0
4 0 52 103832 149208 1530744 0 0 0 236 1481 3273 8 4 87 0 0
2 0 52 88852 149208 1530724 0 0 0 0 1498 3227 43 8 49 0 0
2 0 52 65060 149208 1530756 0 0 44 0 1568 3261 42 9 49 0 0
2 0 52 24808 149208 1530804 0 0 0 0 1478 2785 45 6 49 0 0
0 0 52 110772 149208 1530940 0 0 0 0 1192 2196 25 3 72 0 0
1 0 52 110672 149212 1530908 0 0 0 452 1239 2147 0 1 98 0 0
@sfgeorge
sfgeorge / adhearsion.god
Created April 12, 2013 20:42
An antiquated god watch for Adhearsion
# run with: rvmsudo god -c /srv/phone/phonzy/current/ahn/config/god/adhearsion.god
# debug with: rvmsudo god quit && rvmsudo god -c /srv/phone/phonzy/current/ahn/config/god/adhearsion.god -D
@deploy_path = '/srv/phone/phonzy'
@shared_path = File.join @deploy_path, 'shared'
@app_path = File.join @deploy_path, 'current', 'ahn'
@log_path = File.join @shared_path, 'log'
@pid_path = File.join @shared_path, 'pids'
@pid_file = File.join @pid_path, 'adhearsion.pid'
@god_env = YAML.load_file("#{@shared_path}/config/god_environment.yml")