Skip to content

Instantly share code, notes, and snippets.

@bgswan
bgswan / flatten.rb
Created April 22, 2016 02:27
Example of flattening an Array.
module ArrayHelper
# Returns a new Array which is the result
# flattening any nested arrays.
#
# @param [Array] the array to flatten
# @param [Array] the array to append results to.
#
# @return [Array] the flattened array.
#
@bgswan
bgswan / x-rays.md
Last active May 31, 2018 14:20
Software X-Rays for Ruby

Software Design X-rays

  1. Measure interest rates. Ruby code that changed most frequently in the last year. git log --format=format: --name-only --after="2017-05-18" -- "*.rb" | egrep -v '^$' | sort | uniq -c | sort -r | head -10

  2. Measure size of each file. Lines of code is a simple proxy for complexity. Just Ruby files cloc . --by-file --csv --include-lang=Ruby --quiet

  3. Combine the two into a single output of filename, change_frequency, size.