Skip to content

Instantly share code, notes, and snippets.

View kastner's full-sized avatar
🕳️
actively choosing...

Erik Kastner kastner

🕳️
actively choosing...
View GitHub Profile
#!/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());
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
#!/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
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/",
module Bob
def a
"in bob "
end
end
class A
include Bob
def a
super + (yield).to_s
@kastner
kastner / gist:16288
Created October 11, 2008 16:22 — forked from queso/gist:16284
########## 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
options.scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h }
<?php
require_once("DatabaseClass.php");
Class Customer {
// Member Variables
var $dbHandle;
// Methods
function Customer($dbName = "corked") {
$this->dbHandle = new Database($dbName);
}
<?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()) {