Skip to content

Instantly share code, notes, and snippets.

View timriley's full-sized avatar
🇺🇦
Standing with Ukraine

Tim Riley timriley

🇺🇦
Standing with Ukraine
View GitHub Profile
# 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 }
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
/*
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?
@timriley
timriley / gist:11f6716217b49c4b45a2
Last active August 29, 2015 14:21
Workaround for dismissViewControllerAnimated failing to animate a stack of modal view controllers
- (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:
//
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
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
get "/stylesheets/screen.css" do
content_type 'text/css'
sass :"stylesheets/screen"
end
get "/stylesheets/screen.css" do
content_type 'text/css'
response['Expires'] = (Time.now + 60*60*24*356*3).httpdate
sass :"stylesheets/screen"
end
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
!!! 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'}/