This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This Ugly hack adds Json as one of the types hardcoded to use TEXT. | |
# | |
# The problem this solves is this | |
# | |
# class A | |
# include DataMapper::Resource | |
# property :id, Serial | |
# property :stuff, DataMapper::Types::Json | |
# end | |
# DataMapper.auto_migrate! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RequireSSL | |
def initialize app,options={} | |
@app = app | |
end | |
def call_ env | |
request = ::Rack::Request.new env | |
unless secure? env | |
[302,{"Location"=> request.url.sub('http://','https://')},''] | |
else | |
@app.call env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
args = ARGV.dup | |
snark_for_options = { | |
'-l' => "You can't do anything, you can't even spell sudo", | |
'-s' => "Don't even think of running as the uper suser.", | |
'-b' => "Run it in the background? Hah, fat chance.", | |
'-e' => "Edit which file? Oh wait, you can't" | |
} | |
indent = " "*4 | |
additional_snark = args.map{|arg| indent + snark_for_options[arg].to_s if snark_for_options[arg]}.join "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I doubt this even works, I just was looking at Rack::Auth::Digest::MD5 | |
# and realized that you can't use it with the Rack::Builder dsl because it | |
# needs things set after it has been initialized. | |
# This bothered me, so I blocked this out. | |
# Doing it this way rather than passing a self block allows it to | |
# continue to act like Rack::Auth::Basic does. | |
# My main annoyance was that the interfaces differ in ways that seem to | |
# make little sense to me. | |
module Rack::Auth::UsableDigestMD5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
body_id: not_found | |
title: 404 File Not Found | |
filter: | |
- erb | |
- textile | |
--- | |
h1. <%= @page.title%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=begin | |
I was trying to setup some behavior where if | |
a new object's parent was not saved, I could | |
communicate the errors to the user using the standard model.errors stuff | |
and ran into a problem. | |
'before :save' does not run before :save, it runs before save_self | |
since save looks like this: | |
chainable do | |
def save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomethingAwesome | |
include Singleton | |
def method_missing method,*args | |
instance.send method,*args | |
end | |
alias :old_respond_to? :respond_to? | |
def respond_to? method | |
instance.respond_to?(method) || old_respond_to?(method) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I want to be able to check the validity of the parent object | |
# before saving, and maybe modify it, but I can't use 'before :save' | |
# because those hooks only run if save_parents is true | |
# | |
# I would prefer to not use save_parents because it is part of | |
# the private api, but this seems to be the best solution | |
# I've yet to come across. | |
# | |
require 'rubygems' | |
gem 'dm-core','= 0.10.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# My monkey patch to couchrest to make it work transparently | |
# with couchdb 0.8, the version currently in debian and ubuntu. | |
# | |
#----making couchrest view 0.8 friendly---- | |
#autoloading for monkey patching | |
CouchRest::Server | |
CouchRest::Database | |
module CouchRest |