Skip to content

Instantly share code, notes, and snippets.

View mjpost's full-sized avatar

Matt Post mjpost

View GitHub Profile
@mjpost
mjpost / mid
Created March 19, 2014 17:34
UNIX has `head` and `tail`, but what about when you need a line number in the middle? `mid` provides just that.
#!/usr/bin/perl
# Returns the requested line number from a file or list of files.
# If the line number is given as i:j or i-j, selects that range.
# If no file is given, we read from STDIN.
my $arg = shift;
($num1,$split,$num2) = split(/([:\-\+])/,$arg);
die usage() unless $arg and (! $split or $num2);
@mjpost
mjpost / columnize.pl
Last active August 9, 2017 06:26
I used this for turning a sorted list of reviewers for the NAACL 2013 proceedings into 3 columns of sorted reviewers spanning multiple pages. Two arguments control (a) the number of rows on the first page and (b) the number of rows on subsequent pages.
#!/usr/bin/env perl
# Matt Post <[email protected]>
# April 2013
# This script turns a single column of sorted text into LaTeX-formatted multiple columns spanning
# multiple PDF pages.
# Its input is a single column of text on STDIN (each line is a complete entry). Two optional
# arguments specify (a) the number of rows on the first page and (b) the number of rows on the
# remaining pages, with both defaulting to 45. The last page will be adjusted automatically.