This file contains hidden or 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 ConstantMacros | |
| def with_constants(constants, &block) | |
| saved_constants = {} | |
| constants.each do |constant, val| | |
| saved_constants[ constant ] = Object.const_get( constant ) | |
| Kernel::silence_warnings { Object.const_set( constant, val ) } | |
| end | |
| begin |
This file contains hidden or 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
| import sys | |
| import tweepy | |
| CONSUMER_SECRET = 'xx' | |
| CONSUMER_KEY = 'xx' | |
| # Run this code first to get your auth keys from Twitter | |
| # auth_url = auth.get_authorization_url() | |
| # | |
| # print 'Please authorise: ' + auth_url |
This file contains hidden or 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
| select months.month, | |
| COALESCE(users.count,0) AS count, | |
| lead(count,1) over (order by months) as prev_month, | |
| (count - (lead(count,1) over (order by months)) ) as delta | |
| from | |
| ( | |
| SELECT generate_series( | |
| date_trunc('year', min(created_at)), | |
| now(), | |
| '1 month'::interval |
This file contains hidden or 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
| config.assets.precompile += ['admin.js'] |
This file contains hidden or 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
| To produce: | |
| .blah[class*='span'] { | |
| text-align: center; | |
| } | |
| use: | |
| .blah | |
| &[class*='span'] |
This file contains hidden or 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
| gem "silent-postgres" |
This file contains hidden or 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
| development: | |
| adapter: postgresql | |
| host: localhost | |
| min_messages: warning | |
| database: foo_development |
This file contains hidden or 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
| jQuery.validator.addMethod "min_age", (value, element) -> | |
| date = value.split '-' | |
| dob = new Date date[0], date[1], date[2] | |
| _today = new Date() | |
| _18_years_ago = new Date _today.getYear() - 18, _today.getMonth(), _today.getDay() | |
| return dob < _18_years_ago | |
| , "You must be over 18 years of age to use Nutmeg" | |
| jQuery.validator.addMethod "max_age", (value, element) -> | |
| date = value.split '-' |
This file contains hidden or 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
| AboutYou.any_instance.stub!(:save).and_return(false) | |
| post :create | |
| assigns[:about_you].should be_new_record | |
| flash[:notice].should be_nil | |
| response.should render_template('new') | |
| def create | |
| @about_you = current_user.build_about_you(params[:about_you]) |
This file contains hidden or 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
| def initialize(hash) | |
| hash.each do |k,v| | |
| self.instance_variable_set("@#{k.underscore}", v) | |
| self.class.send(:define_method, k.underscore, proc{self.instance_variable_get("@#{k.underscore}")}) | |
| self.class.send(:define_method, "#{k.underscore}=", proc{|v| self.instance_variable_set("@#{k.underscore}", v)}) | |
| end | |
| end |