Skip to content

Instantly share code, notes, and snippets.

View ahoward's full-sized avatar
💭
probably outside if i'm not hacking.

ara.t.howard ahoward

💭
probably outside if i'm not hacking.
View GitHub Profile
module Foo
def foo; end
end
class FooBar
include Foo
end
module Bar
def Bar.included(other)
# 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"
@ahoward
ahoward / sequence.rb
Created December 29, 2011 17:39 — forked from durran/sequence.rb
Integer sequence ids in Mongo
require 'rubygems'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("test")
end
Mongoid.database.add_stored_function 'sequence', <<-__
function(sequence) {
@ahoward
ahoward / hashlike_bench.rb
Created April 7, 2012 21:23 — forked from copiousfreetime/hashlike_bench.rb
hash like comparison benchmark
#!/usr/bin/env ruby
require 'rubygems'
require "benchmark"
require 'map'
require 'digest/md5'
require 'hashr'
require 'hashie'
def keys( count, start = 'aaaaaa' )
@ahoward
ahoward / gist:3423753
Created August 22, 2012 08:26
Everything you can override in a refinerycms project with refinerycms-blog
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 / gist:3515714
Created August 29, 2012 17:08 — forked from thomasmaas/gist:1013101
How to cache pages and clear them in Refinery CMS
# 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 / set_benchmark.rb
Created August 30, 2012 17:04 — forked from banker/set_benchmark.rb
Which of these is the fastest?
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 / imager.rb
Created September 5, 2012 03:14 — forked from tdreyno/imager.rb
Middleman Imager
require 'base64'
require 'RMagick'
include Magick
module Imager
class << self
def registered(app)
app.send :include, InstanceMethods
app.ready do
@ahoward
ahoward / web-servers.md
Created September 25, 2019 16:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@ahoward
ahoward / web-servers.md
Created September 25, 2019 16:27 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000