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
# app/controller/articles_controller.rb | |
around_filter { |controller, action| controller.send(:add_published_scope, Article){ action.call } } | |
# app/controller/application_controller.rb | |
def add_published_scope(klass = nil, &block) | |
unless klass | |
klass = controller_name.classify.constantize | |
end | |
klass.with_scope(:find => klass.where("published_at <= ?", Time.zone.now)) do | |
yield |
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
# http://stackoverflow.com/a/9460051/148270 | |
describe SomeController do | |
render_views | |
describe "GET 'index'" do | |
before(:each) do | |
@@response ||= begin | |
get 'index' | |
response | |
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
# enable with: | |
# | |
# - content_for :head do | |
# :javascript | |
# window.enable_home_bookmark = true | |
$ -> | |
if window.enable_home_bookmark && (("undefined" != typeof window.navigator.standalone) && !window.navigator.standalone) && navigator.userAgent.match(/iPad/i) != null | |
$('<div id="home_bookmark" style="position:fixed; top: 60px; left: 155px;" ></div>').appendTo('body').popover( | |
placement: 'bottom' |
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
switch (window.orientation) | |
{ | |
case 0: // Portrait | |
break; | |
case 90: ; // Landscape | |
break; | |
case -90: ; // Landscape counterclockwise | |
break; | |
} |
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
%meta{:content => "yes", :name => "apple-mobile-web-app-capable"}/ | |
%meta{:content => "black", :name => "apple-mobile-web-app-status-bar-style"}/ | |
%meta{:content => "minimum-scale = 1.0, maximum-scale = 1.0, initial-scale = 1.0, user-scalable = no", :name => "viewport"}/ | |
%meta{:name => "format-detection", :content => "telephone=no"} | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed.png"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-57x57.png", :sizes => "57x57"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-72x72.png", :sizes => "72x72"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-114x114.png", :sizes => "114x114"}/ | |
%link{:rel => "apple-touch-icon-precomposed", :href => "/assets/apple-touch-icon-precomposed-144x144.png", :sizes => "144x144"}/ |
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
# http://www.tsheffler.com/blog/?p=428 | |
before_filter :cors_preflight_check | |
after_filter :cors_set_access_control_headers | |
# For all responses in this controller, return the CORS access control headers. | |
def cors_set_access_control_headers | |
headers['Access-Control-Allow-Origin'] = '*' | |
headers['Access-Control-Allow-Methods'] = 'POST, GET, OPTIONS' |
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
# encoding: UTF-8 | |
namespace :simulator do | |
desc "Call 'Reset Content and Settings' in iOS Simulator menu" | |
task :reset do | |
%x{ | |
osascript <<-END | |
tell application "iPhone Simulator" to activate | |
tell application "System Events" | |
tell process "iPhone Simulator" |
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
# rails_apps_composer template ~/template.rb -d defaults.yaml | |
# rails new app_name -m ~/template.rb | |
recipes: | |
- apps4 | |
- controllers | |
- core | |
- extras | |
- frontend |
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
#!/usr/bin/ruby | |
def is_git_repo | |
%x[git rev-parse 2>&1] | |
$?.exitstatus == 0 | |
end | |
dir_to_scan = if ARGV[0] | |
if ARGV[0] !~ /^\// | |
"#{Dir.pwd}/#{ARGV[0]}" |
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
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="all.css" media="all" /> | |
<link rel="stylesheet" type="text/css" href="screen.css" media="screen" /> | |
</head> | |
<body> | |
<p class="test_paragraph">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean eleifend congue vehicula. Nullam tempor volutpat nisi et dictum. Vestibulum dictum ipsum massa, eget dapibus est posuere vel. Donec a magna justo. Curabitur et erat non erat porta porttitor. Ut tristique eleifend diam cursus lacinia. Nam ultricies mi tincidunt lobortis tincidunt. Duis ac mi tempus, auctor augue sed, accumsan ante. Nunc dictum tempus ullamcorper. Nunc ullamcorper placerat gravida.</p> | |
<p class="test_paragraph">Maecenas convallis neque tortor, non sodales dui tristique eu. Integer condimentum enim ac mollis sagittis. Suspendisse elementum, tellus quis pretium rutrum, nunc urna eleifend neque, at feugiat ligula justo porta lectus. Praesent in consequat felis. Quisque suscipit auctor mattis. Proin eleifend arcu non l |
OlderNewer