Skip to content

Instantly share code, notes, and snippets.

# Resolving permission corruption
chmod -R 755 photos
find photos/ -type f -perm 755 -print0 | xargs -0 chmod 644
@dejan
dejan / README.txt
Created September 23, 2009 23:47 — forked from rmm5t/README.md
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
<a class="hide" href="javascript:void(0);">hide</a>
@dejan
dejan / gist:123536
Created June 4, 2009 09:27
Nesting params in Rails
>> params = {"line_items"=>[{"quantity"=>"1"}, {"quantity"=>"2"}]}
=> {"line_items"=>[{"quantity"=>"1"}, {"quantity"=>"2"}]}
>> query = CGI::unescape(params.to_query)
=> "line_items[][quantity]=1&line_items[][quantity]=2"
>> parsed_params = ActionController::AbstractRequest.parse_query_parameters(query)
=> {"line_items"=>[{"quantity"=>"1"}, {"quantity"=>"2"}]}
>> params == parsed_params
(0..6).map {|i| i.day.ago.strftime("%a")[0,1] }
@dejan
dejan / test.rake
Created April 11, 2009 18:31
rake test:coverage
namespace :test do
RCOV = "rcov --rails --aggregate coverage.data --text-summary -Ilib"
def rcov_on(files_selector)
unless Dir[files_selector].size == 0
system("#{RCOV} --html #{files_selector}")
end
end
desc 'Measures test coverage'
names.split(/\s*,\s*/).each { |name| ... }
@dejan
dejan / compat-join.rb
Created April 3, 2009 18:22
compact join
[options[:class], clazz].compact * ' '
@dejan
dejan / code filter for haml
Created April 3, 2009 13:59
code filter for haml
module Haml
module Filters
module Code
include Base
def render(text)
text = Haml::Helpers.html_escape(text)
text = Haml::Helpers.preserve(text)
text
end
end
"Poke %s!" % %w{him her}[@user.sex]