This file contains 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 "optparse" | |
DEFAULT_QUANTILES = [0.25, 0.50, 0.75, 0.90, 0.95, 0.99, 0.999] | |
def quantile(values, p, presorted = false) | |
return values.first if values.size == 1 | |
values = values.sort unless presorted | |
hh = (values.size - 1) * p + 1 | |
h = hh.floor |
This file contains 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 php | |
<?php | |
$whitelist = [ | |
"main()", | |
"MemcachePool::get", | |
"PDOStatement::execute", | |
"PDO::commit", | |
"DatabaseStatementBase::execute", | |
"InsertQuery_mysql::execute", |
This file contains 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 php | |
<?php | |
$file_contents = file_get_contents("php://stdin"); | |
$data = unserialize($file_contents); | |
$results = []; | |
foreach ($data as $key => $values) { | |
list($caller, $callee) = explode('==>', $key); |
This file contains 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
def bsearch_index(ary) | |
low = 0 | |
high = ary.length | |
smaller = 0 | |
satisfied = 0 | |
while low < high | |
mid = low + ((high - low) / 2) | |
val = ary[mid] | |
begin |
This file contains 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/ruby | |
require "csv" | |
class Array | |
def sum | |
inject(nil) { |sum,x| sum ? sum+x : x } | |
end | |
def average |
This file contains 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
#!/bin/sh | |
MYSQLDUMP_DIR='/Users/blah/Sites/db_backups' | |
CURDATE=`date +%F` | |
for SITE in $(ls sites/) | |
do | |
if [[ -f sites/${SITE}/settings.php ]] | |
then | |
# Retreive DB information from settings.php file | |
DBURL=$(grep '^$db_url' sites/${SITE}/settings.php | sed "s#.*'\(.*\)'#\1#") |
This file contains 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 'statgrab' | |
require 'json' | |
sg = Statgrab.new | |
stats = {} | |
#puts "#{sg.memory[:free]/1024}m" | |
#puts sg.memory.to_json() |
This file contains 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
#!/bin/bash | |
LATEST=$(curl -o - http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/LATEST) | |
WGET=$(which wget) | |
${WGET} "http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/${LATEST}/chrome-mac.zip" | |
if [[ -f "chrome-mac.zip" ]] | |
then | |
unzip chrome-mac.zip | |
fi |
This file contains 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/ruby | |
require 'rubygems' | |
require 'gdata' | |
require 'zlib' | |
require 'fastercsv' | |
require 'twitter' | |
=begin | |
This script was used at DrupalCamp Dallas 09 to post schedule changes made on a google spreadsheet to twitter. | |
=end |
This file contains 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 | |
/** | |
* Implementation of hook_ctools_context_convert_list(). | |
*/ | |
function misc_ctools_context_convert_list($plugin, &$converters) { | |
if ($plugin['name'] == 'node') { | |
$converters = $converters + array('field_firstname' => t('First Name'), 'field_lastname' => t('Last Name')); | |
} | |
return $converters; | |
} |