Skip to content

Instantly share code, notes, and snippets.

View andrewagain's full-sized avatar

Andrew andrewagain

View GitHub Profile
@andrewagain
andrewagain / gist:40217c6425a7abbbd375
Created January 28, 2015 01:52
Sort lines, ignoring leading and trailing blank lines
#!/usr/bin/ruby
input = STDIN.read
lead_regex = /\A[\n\s]*\n/
tail_regex = /[\n\s]*\Z/
lead_blank = input[lead_regex]
tail_blank = input[tail_regex]