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
This: | |
<p>Please <%= link_to "sign in", :controller => 'account', :action => 'login' %> to comment.</p> | |
Could be: | |
<p> | |
<%= I18n.t('views.formulas.please') %> | |
<%= link_to I18n.t('views.actions.sign_in'), :controller => 'account', :action => 'login' %> | |
<%= I18n.t('views.actions.to_comment') %>. | |
</p> |
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
module RolePlay | |
module PluginMethods | |
def has_roleplay(roles = {}) | |
@@roles = roles | |
@@roles_ids = roles.invert | |
def roles | |
@@roles | |
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
<div id="searchform"> | |
<%= form_tag search_people_path, :method => 'get' do |f| %> | |
<div class="field"> | |
<%= label :search, :firstname, 'Firstname' %><br/> | |
<%= text_field :search, :firstname %> | |
</div> | |
<div class="field"> | |
<%= label :search, :lastname, 'Lastname' %><br/> | |
<%= text_field :search, :lastname %> | |
</div> |
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
class RealtyRequestController < ApplicationController | |
#... other actions ... | |
def search | |
@s = Search.new(RealtyRequest,params[:search]) do |s| | |
s.contract_id :eq # value to search defaults to params[:search][:contract_id] | |
s.price_max :lteq # same here | |
s.price_min :gteq | |
s.zone :matches, "%#{params[:search][:zone]}%" # here I look for '%param%' | |
s.province :matches, "%#{params[:search][:province]}%" | |
s.municipality :matches, "%#{params[:search][:municipality]}%" |
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
# git dirty bash prompt (mostly ripped from http://henrik.nyh.se/2008/12/git-dirty-prompt) | |
# clean repo: | |
# user@host:~/path/to/repo/ [current-branch]$ | |
# dirty repo: | |
# user@host:~/path/to/repo/ [current-branch*]$ | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} |
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
# put at the beginning of your test helper (it doesn't matter which framework you use) | |
unless ENV['COVERAGE'].nil? | |
require 'simplecov' | |
SimpleCov.start 'rails' do | |
coverage_dir 'coverage' | |
end | |
end | |
# then launch your test this way: | |
# COVERAGE=1 rake spec |
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 'http://rubygems.org' | |
gem 'rails', '3.1.0' | |
# Gems used only for assets and not required | |
# in production environments by default. | |
group :assets do | |
gem 'sass-rails', "~> 3.1.0" | |
gem 'coffee-rails', "~> 3.1.0" | |
gem 'uglifier' |
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
# Forked to get it working with Rails 3 and RSpec 2 | |
# | |
# From http://github.com/jaymcgavren | |
# | |
# Save this as rcov.rake in lib/tasks and use rcov:all => | |
# to get accurate spec/feature coverage data | |
# | |
# Use rcov:rspec or rcov:cucumber | |
# to get non-aggregated coverage reports for rspec or cucumber separately |
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
" clear whitespaces when saving buffer | |
" put it in your .vimrc | |
function! Clear_whitespaces() | |
ma a | |
:%s/\s\+$//e | |
'a | |
endfunction | |
autocmd BufWritePre * :call Clear_whitespaces() |
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
def find_longest_palindrome(string) | |
(string.size/2).downto(1) do |n| | |
if m = string.match(Regexp.new("#{'(.)' * (n+1)}?\\#{n.downto(1).to_a.join('\\')}")) | |
return m | |
end | |
end | |
end |
OlderNewer