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
# RSpec's subject method, both implicitly and explicitly set, is useful for | |
# declaratively setting up the context of the object under test. If you provide a | |
# class for your describe block, subject will implicitly be set to a new instance | |
# of this class (with no arguments passed to the constructor). If you want | |
# something more complex done, such as setting arguments, you can use the | |
# explicit subject setter, which takes a block. | |
describe Person do | |
context "born 19 years ago" do | |
subject { Person.new(:birthdate => 19.years.ago } | |
it { should be_eligible_to_vote } |
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
Dir["#{Rails.root}/app/*/**"].each do |dir| | |
case File.basename(dir) | |
when 'assets' | |
Dir["#{dir}/*"].each do |assets_dir| | |
Rails.application.config.assets.paths << assets_dir | |
Dir["#{assets_dir}/*"].each do |asset| | |
parts = File.basename(asset).split('.') | |
name = "#{parts.first}.#{parts.second}" | |
Rails.application.config.assets.precompile += [name] | |
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
/* | |
Just the Notifications, please | |
============================== | |
1. Make a Fluid (http://fluidapp.com/) instance of https://twitter.com/i/notifications | |
2. Apply the below CSS as a Userstyles stylesheet | |
3. Enjoy just the conversation, not the timeline | |
Why? |
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
- (void)loginViewControllerDidClose:(DSLoginViewController *)loginViewController | |
{ | |
// HACK | |
// | |
// Work around a bug(?) where the login VC's view disappears immediately | |
// (without animation) before our own view then animates away. We want | |
// only the login VC's view to animate, with all underlying views | |
// disappearing (invisibly) underneath at the same time. AFAICT, this is | |
// what _should_ happen: | |
// |
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
get "/stylesheets/screen.css" do | |
content_type 'text/css' | |
# Use views/stylesheets & blueprint's stylesheet dirs in the Sass load path | |
sass :"stylesheets/screen", { :sass => { :load_paths => ( | |
[ File.join(File.dirname(__FILE__), 'views', 'stylesheets') ] + | |
Compass::Frameworks::ALL.map { |f| f.stylesheets_directory }) | |
} } | |
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
def sass(template, options={}, &block) | |
require 'sass' unless defined? ::Sass | |
options[:layout] = false | |
render :sass, template, options | |
end | |
def render_sass(template, data, options, &block) | |
engine = ::Sass::Engine.new(data, options[:sass] || {}) | |
engine.render | |
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
get "/stylesheets/screen.css" do | |
content_type 'text/css' | |
sass :"stylesheets/screen" | |
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
get "/stylesheets/screen.css" do | |
content_type 'text/css' | |
response['Expires'] = (Time.now + 60*60*24*356*3).httpdate | |
sass :"stylesheets/screen" | |
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
helpers do | |
def versioned_stylesheet(stylesheet) | |
"/stylesheets/#{stylesheet}.css?" + File.mtime(File.join(Sinatra::Application.views, "stylesheets", "#{stylesheet}.sass")).to_i.to_s | |
end | |
def versioned_js(js) | |
"/javascripts/#{js}.js?" + File.mtime(File.join(Sinatra::Application.public, "javascripts", "#{js}.js")).to_i.to_s | |
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
!!! Strict | |
%html{:xmlns =>'http://www.w3.org/1999/xhtml', 'xml:lang' => 'en', :lang => 'en'} | |
%head | |
%meta{'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}/ | |
%title My Sinatra App | |
%link{:href => versioned_stylesheet('screen'), :media => 'screen', :rel => 'stylesheet', :type => 'text/css'}/ | |
%script{:src => versioned_javascript('application'), :type => 'text/javascript'}/ |
OlderNewer