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
| // Implement generic for two way linked list for different items type. | |
| interface ILinkedList<T> { | |
| append(value: T); | |
| pop():T|null; | |
| showlist():void; | |
| } | |
| class LinkedList<T> implements ILinkedList<T> { | |
| public head:MyNode<T> |
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
| # Идея решения: | |
| # Финальное число точек должно составляется из | |
| # 1. Точки в центре ( начало круга ) ( На рисунке => "0" ) | |
| # 2. Точек лежащих на осях координат, умноженное на четыре | |
| # - так как 4тыре направляющие ( На рисунке => "_" ) | |
| # 3. Точек лежащих на диагональных линиях, умноженное на четыре | |
| # - так как 4тыре направляющие ( На рисунке => "*" ) | |
| # 4. Точки лежащие над и под диагональными линиями, умножаем на 8мь |
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
| # The main idea to install three libraries. | |
| # These libraries can't be symlinked because they are macOs-provided | |
| # > Refusing to link macOS-provided software: libxml2 | |
| # So, You need to specify lib and include directories. | |
| brew install libxml2 | |
| brew install libxslt | |
| brew install libiconv | |
| gem install nokogiri -v '1.6.2.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
| # BEFORE: | |
| describe 'some_description', vcr: true, freezed_time: Time.utc(2016,12,9,15,0,0) do | |
| describe 'some_description', freezed_date: Date.new(2017, 9, 4) do | |
| context 'some_description', freezed_time: Time.new(2016, 0o2, 22, 0o0, 11, 44, "+00:00") do | |
| context 'some_description', freezed_date: Time.new(2016, 01, 20, 17, 43, 56, '+03:00') do | |
| context 'some_description', freezed_date: DateTime.new(2017, 3, 17, 7, 40) do | |
| it 'some_description', freezed_date: Time.utc(2016,11,28,15) do | |
| # AFTER: | |
| describe 'some_description', vcr: true, freezed_time: '2016-12-09T15:00:00+0000' do |
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
| rubocop --format simple \ | |
| --require /absolute/path/to/rewrite_time_cop.rb \ | |
| --only CustomCops/TimecopReplacerCop |
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
| module RuboCop | |
| module Cop | |
| module CustomCops | |
| class TimecopReplacerCop < Cop | |
| MSG = 'Broken rule'.freeze | |
| def on_send(node) | |
| return unless [:describe, :context, :it, :xit, :it_behaves_like].include?(node.method_name) | |
| return unless node.last_argument&.hash_type? # Syntax: "it { is_expected.to be true }" |
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
| module RuboCop | |
| module Cop | |
| module CustomCops | |
| class TimecopReplacerCop < Cop | |
| # ... | |
| def autocorrect(arg_pair) | |
| date_string = eval(arg_pair.value.source).strftime('%Y-%m-%dT%H:%M:%S%z') | |
| new_source = String.new("freezed_time: '#{date_string}'") | |
| ->(corrector) do |
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
| ## EASY: | |
| ``` | |
| def trap(height) | |
| drops = 0 | |
| height.each_with_index do |current_height, i| | |
| max_occupancy = [height[0..i].max, height[i..-1].max].min | |
| drops += max_occupancy - current_height | |
| 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 PostsController < ApplicationController | |
| def index | |
| render cell: :index, model: posts | |
| end | |
| def show | |
| post_view_registrar.commit_view | |
| show_post_page | |
| 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
| namespace :db do | |
| desc 'Convert development DB to Rails test fixtures' | |
| task to_fixtures: :environment do | |
| TABLES_TO_SKIP = %w[ar_internal_metadata delayed_jobs schema_info schema_migrations].freeze | |
| begin | |
| ActiveRecord::Base.establish_connection | |
| ActiveRecord::Base.connection.tables.each do |table_name| | |
| next if TABLES_TO_SKIP.include?(table_name) |