Skip to content

Instantly share code, notes, and snippets.

Cody Caughlan ruckus

Block or report user

Report or block ruckus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:103419
doc = ConvertableDocument.find(params[:id])
redirect_to(:action => :index) and return
View gist:125980
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
View gist:166249
class ExpiresXHRRequests
def initialize(app)
@app = app
def call(env)
is_xhr = env['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
status, headers, body =
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')}"
View gist:227407
<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
View gist:228434
if (!function_exists("getmicrotime")) {function getmicrotime() {list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec);}}
$win = strtolower(substr(PHP_OS,0,3)) == "win";
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;}}
View gist:229493
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
var value = 0;
var type = property.getType();
if(type eq "boolean")
View gist:233355
# 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)
View gist:274789
module ActiveSupport
class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
return if @level > severity
message = (message || (block && || 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
View gist:289027
# Allow for the HTML elements / attributes to be custom specified
# Used like so:
# scrubber = => %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]
View gist:290077
# 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 =
a.get('') do |page|
# Submit the login form
You can’t perform that action at this time.