View donkey
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
donkeys are awesome |
View gist:77472
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
# Norwegian, norsk bokmål, by irb.no | |
"no": | |
support: | |
array: | |
sentence_connector: "og" | |
date: | |
formats: | |
default: "%d.%m.%Y" | |
short: "%e. %b" | |
long: "%e. %B %Y" |
View application_helper.rb
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
module ApplicationHelper | |
def labelled_form_for(*attrs, &proc) | |
options = attrs.last.is_a?(Hash) ? attrs.pop : {} | |
object = attrs.pop | |
options.reverse_merge!( | |
:builder => LabellingFormBuilder | |
) |
View gist:313401
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
module Kernel | |
def recurse(*a, &b) | |
send(caller(1).first[/`(.*?)'\Z/, 1], *a, &b) | |
end | |
end | |
class Foo | |
def bar(stop=false) |
View registerable.rb
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
#Keeps a list of registered names associated with classes at a "base" class | |
#Example: | |
# | |
# class Base | |
# extend Registerable | |
# end | |
# | |
# class Foo < Base | |
# register :foo | |
# end |
View README
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
Facebook Canvas apps are loaded like this: | |
* User clicks link to app or tab ("page as tab") | |
* An iframe is inserted which loads content from the FB server (NOT yours, yet) | |
Something along the lines of: | |
<iframe src="http://facebook.com/page_proxy.php?appid=123"> | |
* The FB server returns some HTML & JS with an automatically submitting form: | |
<form id="humbaba" target="http://you.com/facebook"> | |
<input type="hidden" name="signed_request"/></form> |
View gist:953941
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
# Returns a set of hidden fields for params passed in the query string such that they are passed | |
# along with the form. Mostly for use with GET forms like search/filtering where you want to retain | |
# other state while adding another (<existing params>&q=pr0n) | |
# | |
# Options: | |
# | |
# :skip - An array of keys to leave out - Only works for first-level keys, i.e. not 'bar' in foo[bar]=baz | |
def hidden_fields_from_params(opts={}) | |
#Use CGI.parse to get "raw" parameters that haven't been converted into arrays | |
#and hashes yet. This means it only has to concern itself with the one dimension |
View README
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
User authentication with Rails | |
This is all you need to have fully working and secure authentication in Rails. | |
Why use this instead of <bloated auth framework>? Well, there are a number of | |
reasons, but I guess you'll just have to go through a few apps where you | |
learn the hard way why the idea of a "fully featured" authentication | |
framework that doesn't get on your nerves is a mirage. | |
Don't simply copy and paste this without understanding everything it does. It's |
View explicit.rb
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 PullSource | |
def self.implementations | |
@implementations ||= {} | |
end | |
def self.register(name) | |
implementations[name] << self | |
end |
View gist:1922637
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 Contract < ActiveRecord::Base | |
has_paper_trail | |
acts_as_restful_list | |
CHANGE_FIELDS_MAP = { | |
'contract_status_id' => { | |
:association => 'contract_status' | |
:field => 'name' | |
} |
OlderNewer