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
# WHICH IS BETTER HELPER? | |
# ----------------- | |
%Q{ | |
<div class="invitation-info-box clearfix"><p> | |
#{invite_friends_link} | |
#{t('app.invitation.info_box_signed_in')} | |
</p></div> | |
}.html_safe | |
# ----------------- |
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
-- ratio with average view count log-trend | |
SELECT i.id FROM items i | |
LEFT JOIN global_stats vc ON vc.entry_type=510 AND vc.entry_id = i.id | |
INNER JOIN user_settings s ON s.user_id = i.user_id | |
WHERE s.is_publish_photos_agreed = 1 AND is_visible = 1 AND is_replicated = 0 AND is_reserved = 0 | |
AND boutique_id IS NULL | |
AND created_at >= '2012-10-27' | |
AND i.catalog_id IN (%cat4%) | |
AND vc.value / (LN(DATEDIFF(NOW(),created_at)+1)*15.5+12.4) >= 0.8 | |
ORDER BY id DESC |
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
#!/Ruby192/bin/ruby.exe | |
# | |
# A hook script to verify that only syntactically valid ruby code is commited. | |
# Called by git-commit with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
# | |
# Put this code into a file called "pre-commit" inside your .git/hooks | |
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit") |
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
# using Ruby 1.9.2 | |
# Hole 1, 41 chars | |
def fizzbuzz(n) | |
"#{n%3<1&&f=:Fizz;n%5<1?"#{f}Buzz":f||n}" | |
end | |
# Same as Cyrus's solution, optimized | |
p fizzbuzz(3) # => "Fizz" | |
p fizzbuzz(10) # => "Buzz" |
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 'dm-core' | |
require 'dm-redis-adapter' | |
DataMapper.setup(:default, {:adapter => "redis"}) | |
class Book | |
include DataMapper::Resource | |
property :id, Serial | |
property :name, String |
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
class Binding | |
def publish(vars) | |
defs = vars.each_with_object("") do |var,str| | |
str << "define_method(:#{var}) { #{var} }\n" | |
str << "private :#{var}\n" | |
end | |
self.eval "self.class.module_eval { #{defs} }" | |
end | |
end |
NewerOlder