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
def reverse_1(array) | |
index = array.size - 1 | |
result = [] | |
for i in 0..index do | |
result[index - i] = array[i] | |
end | |
result | |
end |
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
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
# This program modifies the original output of git-churn program https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn. | |
# It highlights current project files in green colour. | |
unless Kernel.system('command -v git-churn &> /dev/null') | |
STDOUT.puts("Install git-churn first. See details at https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn") | |
Kernel.exit | |
end |
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
# Year 2017 | |
module Date | |
def self.difference_in_years(left_date, right_date) | |
# NOTE: xxxx.yyzz (2017.1231) | |
# | |
# xxxx stands for years | |
# yy stands for months | |
# zz stands for days | |
# |
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
# frozen_string_literal: true | |
require 'axlsx' # https://github.com/randym/axlsx | |
require 'rubyXL' # https://github.com/weshatheleopard/rubyXL | |
require 'spreadsheet' # https://github.com/zdavatz/spreadsheet | |
require 'memory_profiler' | |
rows = 1_000 | |
columns = 20 |
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
# 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 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 Dog | |
def hungry? | |
true | |
end | |
def full? | |
false | |
end | |
end |
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
# Year 2014 | |
# encoding: UTF-8 | |
require 'export' | |
require 'export/secure_name' | |
require 'active_support/core_ext/object/blank' | |
describe Export::SecureName do | |
subject { described_class.new('name', '.ext') } |
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 Creature | |
def self.metaclass | |
class << self | |
self | |
end | |
end | |
end |
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 'test/unit' | |
class TestRecursiveReverse < Test::Unit::TestCase | |
def test_o_make | |
assert_equal [3, 2, 1], RecursiveReverse.new.o_make([1, 2, 3]) | |
end | |
def test_f_make | |
assert_equal [3, 2, 1], RecursiveReverse.new.f_make([1, 2, 3]) |
NewerOlder