Skip to content

Instantly share code, notes, and snippets.

doc = ConvertableDocument.find(params[:id])
doc.update_attribute(:confirmed_at, Time.now.utc)
redirect_to(:action => :index) and return
ooga@web12 ext $ sudo ruby extconf.rb
checking for curl-config... yes
checking for curlinfo_redirect_time... yes
checking for curlinfo_response_code... yes
checking for curlinfo_filetime... yes
checking for curlinfo_redirect_count... yes
checking for curlinfo_os_errno... no
checking for curlinfo_num_connects... no
checking for curlinfo_ftp_entry_path... no
checking for curl_version_ssl... yes
class ExpiresXHRRequests
def initialize(app)
@app = app
end
def call(env)
is_xhr = env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
status, headers, body = @app.call(env)
if is_xhr && !headers.has_key?('Expires') # only set if NOT already set
headers['Expires'] = "#{one_week_ago.strftime('%a, %d %b %Y %H:%M:%S GMT')}"
<cfcomponent output="yes">
<!--- Take an object and a struct as input. Traverse through the object's meta-data and
find all methods and if the datastruct contains a key which matches that method name (with "set" prepended)
then call that method using the struct key value.
This is a convenient way to quickly populate an object/bean by calling all of its
setters.
--->
?><?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