Skip to content

Instantly share code, notes, and snippets.

View kryzhovnik's full-sized avatar

Andrey Samsonov kryzhovnik

  • Serbia, Novi Sad
View GitHub Profile
SELECT "users".* FROM "users"
INNER JOIN "addresses" ON "addresses"."user_id" = "users"."id"
INNER JOIN "addresses" "countries_users_join" ON "users"."id" = "countries_users_join"."user_id"
INNER JOIN "countries" ON "countries"."id" = "countries_users_join"."country_id"
INNER JOIN "interests_users" ON "users"."id" = "interests_users"."user_id"
INNER JOIN "interests" ON "interests"."id" = "interests_users"."interest_id"
WHERE
("users"."level" BETWEEN 1 AND 45)
AND ("users"."date_of_birth" BETWEEN '1986-02-09' AND '1991-02-09')
AND ("countries"."title" ILIKE '%d%')
@kryzhovnik
kryzhovnik / Rakefile
Created February 2, 2011 01:42
требует установленного гема loofah (gem install loofah)
desc <<END
Find all html files from the specified directory and clean them: removes comments, whitespaces, and carriage return.
Before using install loofah gem:
gem install loofah
Usage:
rake clean_html DIR=my_dir
Warning: by default, DIR variable point current directory - #{Dir.pwd}
@kryzhovnik
kryzhovnik / en.yml
Created February 2, 2011 01:39
требует установленного гема ya2yaml (gem install ya2yaml)
en:
name:
first: Andrey
last: Samsonov
email: '[email protected]'
github: 'https://github.com/kryzhovnik'
phone: '+7(927)695-8-444'
skype: 'andrey.samsonov'
country: Russia
city: Samara
class InclusionWithBlockValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
begin
enum = options[:in].call
raise unless enum.kind_of?(Enumerable)
rescue
raise "value of :in option at inclusion_with_block validator " +
"must be a block those return enumerable object"
end
unless enum.include?(value)