Skip to content

Instantly share code, notes, and snippets.

View dkubb's full-sized avatar
🏠
Working from home

Dan Kubb dkubb

🏠
Working from home
  • Betterment
  • Mission, BC, Canada
  • X @dkubb
View GitHub Profile
class Bookmark
include DataMapper::Resource
# ...
class Collection
# .. collection specific methods ..
end
end
rcov \
--callsites \
--xrefs \
--exclude spec,lib \
--include-file lib/dm-core/collection.rb \
spec/*/collection_spec.rb
#!/usr/bin/env ruby
# git pre-commit hook
#
# This will ensure 100% code coverage and all specs passing before allowing a commit
# to the git repo.
#
# Place the file at .git/hooks/pre-commit and use chmod a+x to make it executable.
system('rake clean >/dev/null 2>&1')
@dkubb
dkubb / gist:21345
Created October 31, 2008 16:42
Weird Rack::Cache Output
# Output from LiveHTTPHeaders
#
# NOTE: it looks like it's "forgetting" the Content-Type
http://localhost:4000/
GET / HTTP/1.1
Host: localhost:4000
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.3) Gecko/2008092414 Firefox/3.0.3
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
@dkubb
dkubb / gist:21420
Created October 31, 2008 21:13
Merb config/rack.rb with Rack::Cache support
require 'rack/cache'
# use HTTP caching
use Rack::Cache do
import 'rack/cache/config/default'
import 'rack/cache/config/no-cache'
import 'rack/cache/config/busters'
# log cache hit/miss/pass when in development mode
set :verbose, Merb.environment == 'development'
# Rspec Template
# --------------
# 1) Setup the subject. Only really possible when the same object is being
# used for multiple tests. Sometimes the subject will vary based on
# the describe blocks, in which case the subject block will be defined
# inside it.
subject { @string = '' }
@dkubb
dkubb / gist:26009
Created November 18, 2008 00:48
DataMapper release process (for dm-core and dm-more)
# Setup Rubyforge gem
#rubyforge setup # set up username/password
rubyforge login # test username/password
rubyforge config # sync up projects
# Uninstall previous versions of dm-core, dm-more, data objects and extlib
# (From: http://gist.github.com/31187)
gem list '\A(?:(?:d[mo])[_-]|data_?(?:mapper|objects)|extlib)' --no-versions \
@dkubb
dkubb / strip_whitespace.rb
Last active December 21, 2015 20:52
Strips trailing whitespace from source files
#!/usr/bin/env ruby
require 'pathname'
# files and extensions to process
FILES = %w[ capfile Capfile Dockerfile Gemfile Gemfile.devtools Gemfile.lock Guardfile CHANGELOG LICENSE Manifest README README.rdoc README_FOR_APP RUNNING_UNIT_TESTS Rakefile RUBY-STYLE SPECS TODO USAGE Vagrantfile .autotest .gitattributes .gitignore .htaccess .rspec .rcov .rvmrc .travis.yml .vimrc ].freeze
EXTENSIONS = %w[ builder cabal cgi coffee conf css deface deploy erb example fcgi feature handlebars haml hs htc htm html jinja js json key markdown md opts pem php rabl rake ratom rb rcsv rdf rdoc reek rhtml rip rjs rpdf ru rxml sake sass scss sh sls smil sql svg thor txt vcf xml yml ].freeze
paths = ARGV.flat_map(&Pathname.method(:glob))
paths.each do |path_in|
# Embedded Value for DataMapper (http://martinfowler.com/eaaCatalog/embeddedValue.html)
class Address
include DataMapper::EmbeddedValue
property :street, String
property :location, String
property :region, String
property :country, String
end
@dkubb
dkubb / gist:31187
Created December 2, 2008 17:28
Uninstall all versions of dm-core, dm-more, data objects and extlib
gem list '\A(?:(?:d[mo])[_-]|data_?(?:mapper|objects)|extlib)' --no-versions \
| xargs gem uninstall -aIx