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
# This snippet adds any and all CSS and JS files in asset directories to list of precompiled assets. | |
# Avoid the dreaded 'whatever.js isn't precompiled' error | |
config.assets.precompile += Dir['app/assets/stylesheets/**/*.css'].map{|f| f.gsub('app/assets/stylesheets/','')} | |
config.assets.precompile += Dir['app/assets/javascripts/**/*.js'].map{|f| f.gsub('app/assets/javascripts/','')} | |
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
When 'I signup as "$nickname" with email "$email" and password "$password"' do |nickname, email, password| | |
find('.toggle-signup-block').click | |
find('#signup-regular').click | |
find('.cp_signup_nickname input.r').set nickname | |
find('.cp_signup_email input.r').set email | |
find('.cp_signup_password input.tip').click | |
find('.cp_signup_password input.password').set password | |
find('.cp_day .opener').click | |
find('.cp_day li[text()="1"]').click | |
find('.cp_month .opener').click |
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
require 'cgi' | |
require 'nokogiri' | |
def escape_pres(text) | |
doc = Nokogiri::HTML(text) | |
pres = doc.css('pre').select do |pre| | |
# Select only PREs that don't have PREs as parents | |
# Slow but works | |
tag = pre.parent |
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
en: | |
success_messages: | |
update: Foo was updated | |
create: Foo was created |
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 '/services/:id', :to => 'service_types#show', :as => :service_type, :constraints => SlugConstraint.new(ServiceType, :position => 2) |
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
# This code isn't safe; at least add escaping to the url and the params. | |
class ActionController::Base | |
def redirect_using_post(url, params) | |
render :text => %Q{<form action="#{url}">#{params.map{|k,v| %Q{<input type= | |
hidden" name="#{k}" value="#{v}" />}}.join('')}</form><script>document.forms[0].submit()</script>} | |
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
pg=# explain analyze SELECT * FROM "companies" WHERE ((lower(companies.title) LIKE 'c%') AND ("companies"."custom" = 'false')) ORDER BY title ASC LIMIT 100 | |
; | |
QUERY PLAN | |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
Limit (cost=50411.91..50412.16 rows=100 width=817) (actual time=16646.708..16646.900 rows=100 loops=1) | |
-> Sort (cost=50411.91..50413.52 rows=647 width=817) (actual time=16646.701..16646.773 rows=100 loops=1) | |
Sort Key: title | |
Sort Method: top-N heapsort Memory: 66kB | |
-> Bitmap Heap Scan on companies (cost=7678.75..50387.18 rows=647 width=817) (actual time=1084.527..16643.838 rows=795 loops=1) | |
Filter: ((NOT custom) AND (lower((title)::text) |
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
<div class='paginator'> | |
{% if paginator.next_page %} | |
<div class='paginator-next'> | |
<a href='/page{{paginator.next_page}}'> | |
Earlier posts → | |
</a> | |
</div> | |
{% endif %} | |
{% if paginator.previous_page %} | |
<div class='paginator-prev'> |
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
task :default_cities => :environment do | |
require 'fastercsv' | |
city_map = City.all.inject({}) do |cities, city| | |
cities[city.name] ||= [] | |
cities[city.name] << city | |
cities | |
end | |
population = {} |
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
found = %w(html body h1 h2 h3 h4 h5 h6 a ul ol li p div i b strong em) | |
not_found = [] | |
File.read('app/stylesheets/common.sass').each do |line| | |
next if line =~ /^[\s|@|\/]/ | |
elements = line.strip.split(/[^\w\-_]/).reject{|l| l==''}.reject{|l| found.include?(l) || not_found.include?(l)} | |
elements.each do |element| | |
result = `ack-grep #{element} --nocss` | |
if result.length>0 | |
puts element |