Skip to content

Instantly share code, notes, and snippets.

?><?php
if (!function_exists("getmicrotime")) {function getmicrotime() {list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec);}}
error_reporting(5);
@ignore_user_abort(TRUE);
@set_magic_quotes_runtime(0);
$win = strtolower(substr(PHP_OS,0,3)) == "win";
define("starttime",getmicrotime());
if (get_magic_quotes_gpc()) {if (!function_exists("strips")) {function strips(&$arr,$k="") {if (is_array($arr)) {foreach($arr as $k=>$v) {if (strtoupper($k) != "GLOBALS") {strips($arr["$k"]);}}} else {$arr = stripslashes($arr);}}} strips($GLOBALS);}
$_REQUEST = array_merge($_COOKIE,$_POST);
foreach($_REQUEST as $k=>$v) {if (!isset($$k)) {$$k = $v;}}
diff --git a/transfer/com/sql/SQLValue.cfc b/transfer/com/sql/SQLValue.cfc
index a027eee..521b7d1 100644
--- a/transfer/com/sql/SQLValue.cfc
+++ b/transfer/com/sql/SQLValue.cfc
@@ -46,6 +46,7 @@ Mark Mandel 04/04/2008 Created
<cfscript>
var value = 0;
var type = property.getType();
if(type eq "boolean")
# t.column "latitude", :decimal, :precision => 10, :scale => 4, :default => 0.0, :null => false
# t.column "longitude", :decimal, :precision => 10, :scale => 4, :default => 0.0, :null => false
# def want index on both
def find_nearby(radius = 10, limit = 10)
distance_sql = <<-SQL_END
IFNULL(SQRT( ((69.1 * (#{self.latitude} - zips.latitude)) * (69.1 * (#{self.latitude} - zips.latitude)))
+ ( (53 * (#{self.longitude} - zips.longitude)) * (53 * (#{self.longitude} - zips.longitude)))),0)
SQL_END
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && block.call) || progname).to_s
# If a newline is necessary then create a new message ending with a newline.
# Ensures that the original message is not mutated.
message = "#{message} (pid:#{$$})\n" unless message[-1] == ?\n
buffer << message
auto_flush
# Allow for the HTML elements / attributes to be custom specified
# Used like so:
# scrubber = WhitelistScrubber.new(:whitelist_elements => %w(span div) , :whitelist_attributes => %w(style class) )
# cleaned = Loofah.fragment(input).scrub!(scrubber).to_s
# This scrubber does not have graceful degradation when the elements/attributes are NOT set.
class WhitelistScrubber < Loofah::Scrubber
attr_accessor :whitelist_elements, :whitelist_attributes
def initialize(options = {}, &block)
if options[:whitelist_elements]
# If you DONT automatically resolve your errors on each deploy than they accumulate in HopToad
# Unfortunately HopToad doesnt offer a way to mass edit errors (mark them as resolved, specifically)
# This script to the rescue
require 'rubygems'
require 'mechanize'
a = WWW::Mechanize.new
a.get('https://yourdomain.hoptoadapp.com/login') do |page|
# Submit the login form
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://medpediamedia.com.s3.amazonaws.com/jquery.gbox.js" type="text/javascript"></script>
<style type="text/css">
.gbox_dialog, .gbox {
display: none;
border: 3px solid #00f;
# MySQL BLOB logging filter.
#
class ActiveRecord::ConnectionAdapters::AbstractAdapter
# Replace BLOB portion of message with "BLOB(n bytes)".
#
# ==== Paramters
def format_log_entry_with_blob_filter(message, dump = nil)
dump.gsub!(/x'[^']+'/) { |blob| "BLOB(#{(blob.length-3)/2} bytes)" } if dump
format_log_entry_without_blob_filter(message, dump)
# in config/initializer/cache_money.rb
# disabling CacheMoney as of 3/12/2009 to see how the site performs w/o
# such heavy-handed caching enabled
if false
#false && (['staging', 'production'].include?(RAILS_ENV) || ENV['CACHEMONEY'] == 'true')
require 'cache_money'
config = YAML.load(IO.read(File.join(RAILS_ROOT, "config", "memcached.yml")))[RAILS_ENV]
$memcache = MemCache.new(config)
source "http://gems.rubyforge.org"
source "http://gems.github.com"
gem "rails", "2.3.2"
gem "hpricot", "0.8.1"
gem "aws-s3", "0.6.2", :require => "aws/s3"
gem "syphon", ">= 0.4.0"
gem "image_science"
gem "rugalytics", ">= 0.2.0"
gem "feedzirra"