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
| ###################################################### | |
| # Meta? # | |
| ###################################################### | |
| def q obj, &proc # # | |
| proc.call(obj) # # | |
| obj ### # | |
| end # # | |
| ########## # | |
| def q2 obj, &proc #################### # | |
| proc.call("What does this variable mean?",obj)## # |
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 FilteredFunction | |
| attr :func | |
| attr :filters | |
| alias :to_proc :func | |
| def initialize func | |
| @func = func | |
| @filters = {} |
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
| %ul.filter | |
| - form_for :filter, { :url => dump_admin_users_path } do |f| | |
| %li | |
| = f.label :start_date, "От" | |
| = date_field f, :start_date, :default => Statistics::Users.start_date_default | |
| %li | |
| = f.label :end_date, "До" | |
| = date_field f, :end_date, :default => Statistics::Users.end_date_default | |
| %li | |
| = f.label :city_id, "Город" |
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
| @import compass/utilities/general/clearfix | |
| @import compass/reset | |
| @import compass/css3/border-radius | |
| @import compass/css3/box-shadow | |
| @import compass/css3/text-shadow | |
| @import compass/css3/gradient | |
| !main-color= #e53596 | |
| !text-color= black |
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 self.for_homepage scope | |
| number, per_user, offset = 200, 10, 0 | |
| scope = scope.skip_moderators.skip_hidden.limit(number).last_month | |
| res = ActiveSupport::OrderedHash.new { |h,k| h[k] = [] } | |
| while res.size < 10 | |
| skipped = res.map { |k, v| v.size > per_user ? nil : k }.compact | |
| data = scope.offset(offset).user_id_not_in(skipped).all(:include => {:user => :avatar}).group_by(&:user_id) | |
| break if data.empty? | |
| offset += number | |
| data.each { |k, v| res[k] += v } |
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 tag label, &block_given | |
| if block_given? | |
| @filters << lambda {|item| if check(:tag, label)[item]; block_given.call(item); end } | |
| else | |
| check(:tag, label) | |
| end | |
| end | |
| def state label, &block_given | |
| if block_given? |
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
| #EX TODO rewrite if we stick with Ruby 1.9 | |
| [:tag, :state, :either, :every].each do |keyword| | |
| define_method("_fake_#{keyword}") do |block, *conditions| | |
| if block | |
| @filters << lambda {|item| if check(keyword, conditions)[item]; block.call(item); end } | |
| else | |
| check(keyword, conditions) | |
| end | |
| 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
| exists :dream_id, :price_id do | |
| every((state :done), (tag :test)) do |item| | |
| puts "every" | |
| end | |
| either((state :not_done), (tag :test)) do |item| | |
| puts "either" | |
| 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
| # if story has label "need_content" then create | |
| # new ticket in todoist in copyrighter's project | |
| tag :need_content do |item| | |
| item.new_link(:todoist, { | |
| :state => :new, | |
| :owner => :copyrighter}) | |
| end | |
| # if story has label "need_confirmation" and there is a linked task | |
| # in todoist then create new task in todoist with the same onwer and |
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
| import Data.List (sort) | |
| import Data.Maybe (isJust, fromJust) | |
| checkWords :: [[String]] -> String | |
| checkWords [] = "Can't match" | |
| checkWords (xs:ys) | length xs == 1 = head xs | |
| | otherwise = checkWords ((unfold (trans (head xs)) (tail xs)) ++ ys) | |
| where trans x y | head x == last y = Just (y ++ x) | |
| | head y == last x = Just (x ++ y) | |
| | otherwise = Nothing |