This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo aptitude install sysbench | |
echo "create database sbtest; grant all on sbtest.* to 'sbtest'@'localhost';" | mysql | |
sysbench --test=oltp --num-threads=10 prepare | |
sysbench --test=oltp --num-threads=10 run | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'fog' | |
ACCESS_KEY_ID='BLARGH' | |
SECRET_ACCESS_KEY='BLARGH' | |
ZERIGO_EMAIL='BLARGH' | |
ZERIGO_TOKEN='BLARGH' | |
ZERIGO_ZONE='BLARGH' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VarnishPlugin < Scout::Plugin | |
def build_report | |
stats = {} | |
`varnishstat -1`.each_line do |line| | |
#client_conn 211980 0.30 Client connections accepted | |
next unless /^(\w+)\s+(\d+)\s+(\d+\.\d+)\s(.+)$/.match(line) | |
stats[$1.to_sym] = $2.to_i | |
end | |
report(:hitrate => 1 - (stats[:cache_miss].to_f / stats[:cache_hit])) | |
counter(:backend_success, stats[:backend_conn], :per=>:second) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/php | |
<?php | |
$bannedWords = array_filter(array_map('trim',file('/Users/lachlan/.bannedwords'))); | |
$output = array(); | |
$return = 0; | |
exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return); | |
$against = $return == 0 ? 'HEAD' : '4b825dc642cb6eb9a060e54bf8d69288fbee4904'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
class RubyBridge | |
def call(env) | |
response = [] | |
data = JSON.dump(env) | |
IO.popen("php ./rackup.php", 'r+') do |io| | |
io.write data | |
io.close_write |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Mixin | |
{ | |
private $__map=array(); | |
public function __call($method, $params) | |
{ | |
if(!isset($this->__map[$method])) | |
throw new BadMethodCallException("$method not defined"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Mixin; | |
class Mixin | |
{ | |
private $__map=array(); | |
public function __call($method, $params) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// original api using static classes | |
$collection = Braintree_Transaction::search(array( | |
Braintree_TransactionSearch::orderId()->startsWith('a2d'), | |
Braintree_TransactionSearch::customerWebsite()->endsWith('.com'), | |
Braintree_TransactionSearch::billingFirstName()->is('John'), | |
Braintree_TransactionSearch::status()->in(array( | |
Braintree_Transaction::AUTHORIZED, | |
Braintree_Transaction::SETTLED |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'rb-fsevent' | |
require 'optparse' | |
require 'net/ssh' | |
require 'net/sftp' | |
def watch_directory(sftp, watch_dir, target_dir) | |
fsevent = FSEvent.new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'varnish/test' | |
class HelloWorldTest < Varnish::Test::TestCase | |
def test_it_says_hello_world | |
backend = Varnish::Test::Backend.new | |
backend.expect :get, '/', do |env| | |
[ 200, {}, "Hello World" ] | |
end |