Skip to content

Instantly share code, notes, and snippets.

# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@Kosmas
Kosmas / percentages_display
Created October 20, 2015 12:56
display percentages in a rake task
def calculate_perc(i, total)
(i * 100 / total).to_i
end
def rate_limit_1_perc?(perc, last_perc, last_updated)
# Changes of at least 1%
# once every 20 seconds
perc > last_perc && last_updated < Time.now.ago(20.seconds)
end
test_helper.rb
require './test/additional_assertions'
additional_assertions.rb
module AdditionalAssertions
module CaptureOutput
# NOTE: MiniTest has capture_io and capture_subprocess_io
@Kosmas
Kosmas / gist:e2772e2cf89e918ae66a4d61586d572d
Created August 30, 2016 11:13
Alias for running Code Climate CLI (cca) - add in .bashrc
alias cca="docker run --interactive --tty --rm --env CODECLIMATE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate analyze"