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
| # NOTE: There are Application pages we need to calculate progress for. | |
| # Every page has specific rules/conditions how to estimate progress. | |
| # Rules have scores/weights and they are used to calculate progress. | |
| # pages = { | |
| # home_page: { home_page_rule => score }, | |
| # info_page: { info_page_rule_1 => score_1, info_page_rule_2 => score_2 } | |
| # } | |
| module ApplicationProgress | |
| module Rules |
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
| (ns alice.pagination) | |
| (defn paginate | |
| "Split lines into pages" | |
| ([lines lines-per-page] | |
| (paginate lines lines-per-page [])) | |
| ([lines lines-per-page pages] | |
| (if (empty? lines) | |
| pages | |
| (paginate (drop lines-per-page lines) |
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
| (defn show-page | |
| [request] | |
| (let [page-number (read-string (get-in request [:path-params :id]))] | |
| (if (and (> page-number 7) (not (session/authenticated? request))) | |
| (ring-resp/redirect "/sign-in") | |
| (ring-resp/response (views/book-page book page-number))))) |
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
| require 'temp_crawler/storage' | |
| describe Storage do | |
| subject(:storage) { described_class.new(name: 'name') } | |
| before { storage.clear } | |
| describe '#add(value)' do | |
| it 'adds a uniq value' do | |
| expect { storage.add('*') }.to change { storage.size }.by(1) |
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
| require 'redis' | |
| class Storage | |
| def initialize(name:) | |
| @name = name | |
| @storage = Redis.new | |
| end | |
| def add(value) |
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
| require 'benchmark/ips' | |
| @alphabet = Range.new('a', 'z').to_a.join(',') | |
| def slow | |
| @alphabet.gsub(',', '') | |
| end | |
| def fast | |
| @alphabet.delete(',') |
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 Something | |
| def happen(dependency) | |
| dependency.use | |
| end | |
| end | |
| class Dependency | |
| def initialize | |
| @used = false | |
| 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
| class Player | |
| attr_reader :name, :turn | |
| def initialize(name, turn) | |
| @name = name | |
| @turn = turn | |
| end | |
| end | |
| class Judge |
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 GameElementsFactory | |
| def self.sample(type = nil) | |
| selected_type = if type.nil? | |
| self.types.values.sample | |
| else | |
| self.types.fetch(type) | |
| end | |
| selected_type.new | |
| end |