Skip to content

Instantly share code, notes, and snippets.

def reverse_1(array)
index = array.size - 1
result = []
for i in 0..index do
result[index - i] = array[i]
end
result
end
@mkaschenko
mkaschenko / git-churn.rb
Last active February 11, 2021 16:43
Provides churn statistics (frequency of change) for git repositories
#!/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
@mkaschenko
mkaschenko / difference_in_years.rb
Last active March 1, 2025 06:24
The difference in years between dates
# Year 2017
module Date
# NOTE: There are two scenarios to consider based on the order of input dates:
# 1. Ascending order: Only negative differences in days and/or months affect the year count.
# 2. Descending order: Only positive differences in days and/or months affect the year count.
def self.difference_in_years(left_date, right_date)
diff_in_years = right_date.year - left_date.year
diff_in_months = (right_date.month - left_date.month) / 100.0
diff_in_days = (right_date.day - left_date.day) / 10_000.0
Total allocated: 866310180 bytes (12591137 objects)
Total retained: 33023440 bytes (462320 objects)
allocated memory by gem
-----------------------------------
294156420 axlsx-3.0.0.pre
227658977 activerecord-4.0.12
208460068 activesupport-4.0.12
42440348 pathgather-service/app
36606762 bullet-4.9.0
Total allocated: 866310180 bytes (12591137 objects)
Total retained: 33023440 bytes (462320 objects)
allocated memory by gem
-----------------------------------
294156420 axlsx-3.0.0.pre
227658977 activerecord-4.0.12
208460068 activesupport-4.0.12
42440348 pathgather-service/app
36606762 bullet-4.9.0
# frozen_string_literal: true
require 'rubyXL' # https://github.com/weshatheleopard/rubyXL
rows = 60_000
columns = 20
workbook = RubyXL::Workbook.new
worksheet = workbook.worksheets[0]
worksheet.sheet_name = 'Test'
# 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
# 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 module runs a full profile sync for a specific user, depending on which
# integrations are enabled. It supports all existing transcript and assignment
# integrations.
module UserProfileSyncs
def self.sync(company, user)
integrations = IntegrationsDispatcher.history_integrations +
IntegrationsDispatcher.assignment_integrations
integrations = IntegrationsDispatcher.select_enabled(integrations, company, user)
[ 02/17/2018 16:33:15 ]
Bitfinex: 10810.00 / 10811.00
OKCoin: 11531.78 / 11630.28
Bitstamp: 10821.86 / 10836.85
Gemini: 10850.00 / 10855.06
Kraken: 10847.00 / 10853.20
ItBit: 10850.00 / 10850.27
Poloniex: 10816.00 / 10816.00
GDAX: 10834.99 / 10835.00
QuadrigaCX: 10750.00 / 10900.00