Skip to content

Instantly share code, notes, and snippets.

@gettalong
gettalong / gist:2869794
Created June 4, 2012 17:46
Using Ruby in a Bash function to shorten the CWD
function shorten_pwd {
ruby -e "puts Dir.pwd.sub(/^#{ENV['HOME']}/, '~').split('/').map {|l| l.length > 6 ? l[0,3] << '…' << l[-3,3] : l}.join('/')"
}
@gettalong
gettalong / small_benchmarks.rb
Created June 2, 2012 06:11
Some small benchmarks used during the creation of kramdown
# -*- coding: utf-8 -*-
require 'benchmark'
class Test
CONST = 5
N = 1_000_000
def test_const
Benchmark.bm 20 do |results|
results.report 'one' do