Skip to content

Instantly share code, notes, and snippets.

💭
skiing

ara.t.howard ahoward

💭
skiing
Block or report user

Report or block ahoward

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
@ahoward
ahoward / imager.rb
Created Sep 5, 2012 — forked from tdreyno/imager.rb
Middleman Imager
View imager.rb
require 'base64'
require 'RMagick'
include Magick
module Imager
class << self
def registered(app)
app.send :include, InstanceMethods
app.ready do
@ahoward
ahoward / set_benchmark.rb
Created Aug 30, 2012 — forked from banker/set_benchmark.rb
Which of these is the fastest?
View set_benchmark.rb
x = 10000.times.to_a
a,b,c = x.dup, x.dup, x.dup
Benchmark.measure { 1000.times { out = []; out += a; out += b; out +=c; out.uniq! } }
Benchmark.measure { 1000.times { out = Set.new; out += a; out += b; out +=c; } }
Benchmark.measure { 1000.times { out = {}; a.each {|e| out[e] ||= 1}; b.each {|e| out[e] ||= 1}; c.each {|e| out[e] ||= 1}; } }
@ahoward
ahoward / gist:3515714
Created Aug 29, 2012 — forked from thomasmaas/gist:1013101
How to cache pages and clear them in Refinery CMS
View gist:3515714
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@ahoward
ahoward / gist:3423753
Created Aug 22, 2012
Everything you can override in a refinerycms project with refinerycms-blog
View gist:3423753
When starting a project that includes refinerycms-blog:
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
@ahoward
ahoward / hashlike_bench.rb
Created Apr 7, 2012 — forked from copiousfreetime/hashlike_bench.rb
hash like comparison benchmark
View hashlike_bench.rb
#!/usr/bin/env ruby
require 'rubygems'
require "benchmark"
require 'map'
require 'digest/md5'
require 'hashr'
require 'hashie'
def keys( count, start = 'aaaaaa' )
@ahoward
ahoward / sequence.rb
Created Dec 29, 2011 — forked from durran/sequence.rb
Integer sequence ids in Mongo
View sequence.rb
require 'rubygems'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("test")
end
Mongoid.database.add_stored_function 'sequence', <<-__
function(sequence) {
View Rails MongoMapper Template.rb
# mongo_template.rb
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842)
#
# To use:
# rails project_name -m http://gist.github.com/gists/219223.txt
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
View scratch.rb
module Foo
def foo; end
end
class FooBar
include Foo
end
module Bar
def Bar.included(other)
You can’t perform that action at this time.