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
# Make sure that we don't allow attributes to be mass assigned from Backbone saves | |
# http://www.quora.com/Backbone-js-1/How-well-does-backbone-js-work-with-rails | |
# Always whitelist and validate your incoming attributes. | |
# | |
# Usage | |
# | |
# model.update_attributes pick(params, :title, :description) | |
# | |
def pick(hash, *keys) | |
filtered = {} |
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
# normal Gem dependancy declarations | |
# ... | |
group :test, :cucumber do | |
gem 'pdf-reader' | |
end |
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
# Creates Tempfile | |
def ical_file | |
file = Tempfile.new("foo") | |
begin | |
file.path | |
file.write('foo') | |
file.rewind | |
file.read | |
ensure | |
file.close |
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
# Model | |
class Meeting < ActiveRecord::Base | |
scope :date_range, lambda {|*args| where("start_date between ? and ?", args.first, args.last) } | |
end | |
#Controller | |
# fullcalendar.js dates displays | |
def meeting_dates | |
start_range = params[:start].present? ? Time.at(params[:start].to_i) : Date.civil(Time.now.year, Time.now.month, 1) |
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
after "deploy:stop", "delayed_job:stop" | |
after "deploy:start", "delayed_job:start" | |
after "deploy:restart", "delayed_job:restart" | |
namespace :delayed_job do | |
desc "Stop the delayed_job process" | |
task :stop, :roles => :app do | |
run "cd #{current_path}; script/delayed_job -e #{rails_env} stop" | |
end | |
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
# | |
# Recurring Job using Delayed::Job | |
# | |
# Setup Your job the "plain-old" DJ (perform) way, include this module | |
# and Your handler will re-schedule itself every time it succeeds. | |
# | |
# Sample : | |
# | |
# class MyJob | |
# include Delayed::ScheduledJob |
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
increment = do -> | |
x = 0 | |
-> | |
x++ |
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
source :rubygems | |
gem 'sinatra' | |
gem 'oauth2' | |
gem 'json' | |
group :test do | |
gem 'rspec' | |
gem 'rack-test' | |
end |
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
# Add fixture-generation methods to ControllerExampleGroup. We load | |
# this file within our spec_helper.rb | |
# http://pivotallabs.com/users/jb/blog/articles/1152-javascripttests-bind-reality- | |
Spec::Rails::Example::ControllerExampleGroup.class_eval do | |
# Saves the markup to a fixture file using the given name | |
def save_fixture(markup, name) | |
fixture_path = File.join(RAILS_ROOT, '/tmp/js_dom_fixtures') | |
Dir.mkdir(fixture_path) unless File.exists?(fixture_path) |
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
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |