Skip to content

Instantly share code, notes, and snippets.

Rob Hurring robhurring

Block or report user

Report or block robhurring

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
robhurring / any.js
Created Feb 18, 2009
Allow strings to number_to_currency style comma seperate in javascript
View any.js
// Allow strings to number_to_currency style comma seperate
String.prototype.commafy = function () {
return this.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) {
return $1 + $2.replace(/\d(?=(?:\d\d\d)+(?!\d))/g, "$&,");
// Convenience method for numbers
Number.prototype.commafy = function () {
return String(this).commafy();
robhurring / application.html.erb
Created Mar 16, 2009
Rails Metal theme switcher
View application.html.erb
# your applications main layout file (app/views/layouts/application.html.erb?)
# I put this after the normal stylesheet call, so our theme can override what we want instead of the entire stylesheet
<% if theme = request.env['rails.theme'] %>
<%= stylesheet_link_tag "themes/#{theme}", :media => :all %>
<% end %>
robhurring / any.html.erb
Created Mar 24, 2009
object debugging with syntax highlight
View any.html.erb
<!-- using -->
<%= syntax_debug @object %>
robhurring / shBrushRuby.js
Created Jul 17, 2009
GitHub style syntax highlighter theme
View shBrushRuby.js
* SyntaxHighlighter
* SyntaxHighlighter is donationware. If you are using it, please donate.
* @version
* 2.0.320 (May 03 2009)
robhurring / fuzzy_date.php
Created Feb 11, 2010
PHP fuzzy date function
View fuzzy_date.php
function fuzzy_date($timestamp)
$myDays = array("Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat");
if( preg_match("/[-\/:]/", $timestamp) )
$timestamp = strtotime($timestamp);
if($timestamp > time())
// All future dates
robhurring /
Created Mar 24, 2010
Sinatra using ActiveRecord's Query Caching ability across multiple Databases :
require 'sinatra_query_caching_demo'
run Demo
robhurring / diff.rb
Created Mar 26, 2010
Ruby Diff -- Ghetto style!
View diff.rb
require 'tempfile'
# TODO: do some pre-comparison on a and b so we can skip creating temp files and all that jazz.
# NOTE: this is so ghetto ;)
module Diffable
def diff(b, options = {}), b, options).diff
robhurring / renderer.php
Created Mar 29, 2010
PHP Template Rendering
View renderer.php
class MissingTemplateException extends Exception {}
function render_template($template_file, $vars = array())
View filters.rake
namespace :filters do
desc 'List all filter permissions'
task :list => :environment do
controllers = Dir[Rails.root.to_s+'/app/controllers/**/*_controller.rb'].map{ |f| File.basename(f).gsub(/\.rb$/, '').classify }.sort
controllers.each do |controller|
filters = controller.constantize.filter_chain
puts controller
filters.each do |filter|
puts "\t#{filter.method}"
puts "\t\t" << filter.options.inspect unless filter.options.blank?
View insecure.php
// Check for the session[user_id] param to see if the user is logged in
echo 'This is my secret page.'
// curl http://localhost/insecure.php
You can’t perform that action at this time.