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/php | |
<?php | |
define("BASE32", "0123456789bcdefghjkmnpqrstuvwxyz"); | |
function geo_hash_decode($geo_hash) { | |
$ones_and_zeros = array_map("chr2bin", str_split($geo_hash, 1)); | |
$exploded = str_split(join($ones_and_zeros, ""), 1); | |
$l_l = array(0 => array(), 1 => array()); |
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
require 'syslog' | |
def log(message) | |
# $0 is the current script name | |
Syslog.open($0, Syslog::LOG_PID | Syslog::LOG_CONS) { |s| s.warning message } | |
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
#!/usr/bin/env ruby | |
def lines | |
@input ||= STDIN.read | |
lines = 0 | |
@input.each_line do |line| | |
line.split(/\|/).each_with_index do |c, i| | |
yield lines, c, i | |
end | |
lines += 1 | |
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
function _parseHTML(html) { | |
var doc = context.focusedWindow.document; | |
var div = doc.createElement( "div" ); | |
div.innerHTML = html; | |
return div; | |
} | |
CmdUtils.CreateCommand({ | |
name:"toggle-these", | |
homepage: "http://metaatem.net/", |
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
module Bob | |
def a | |
"in bob " | |
end | |
end | |
class A | |
include Bob | |
def a | |
super + (yield).to_s |
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
########## Why does the yield output outside the content_tag block? | |
# Method | |
def submit(*args) | |
block_output = yield | |
@template.content_tag(:div, :class => "save_actions") { | |
super(*args) + block_output | |
} | |
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
hi |
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
options.scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h } | |
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 | |
require_once("DatabaseClass.php"); | |
Class Customer { | |
// Member Variables | |
var $dbHandle; | |
// Methods | |
function Customer($dbName = "corked") { | |
$this->dbHandle = new Database($dbName); | |
} |
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 | |
function findInRange($start, $end, $dbHandle) { | |
$found_ids = array(); | |
$days = (strtotime($end) - strtotime($start)) / 60 / 60 / 24; | |
for($i=0; $i<=$days; $i++) { | |
$day = date("Y-m-d", strtotime($start) + ($i * 60 * 60 * 24)); | |
$query = "SELECT id FROM events WHERE start_date <= '$day' AND '$day' <= end_date"; | |
$sth = $dbHandle->query($query); | |
while ($row = $sth->fetch()) { |