Skip to content

Instantly share code, notes, and snippets.

@benizi
Last active September 23, 2017 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benizi/0c0056aa185ff1fc03abe2860f5cce5e to your computer and use it in GitHub Desktop.
Save benizi/0c0056aa185ff1fc03abe2860f5cce5e to your computer and use it in GitHub Desktop.
history of one liner
perl -Mstrict -wE 'my(@I,%h,@q,%S);sub J{join":",@_}sub P{my$s=$_;map substr($s,0,$_),1..length$s}while(<STDIN>){chomp;my@f=split/:/;push@I,\@f;my$h=\%h;$h=($$h{$_}//={})for@f}@q=[\%h];while($_=shift@q){my($h,@p)=@$_;if(my@k=keys%$h){my%u;$u{$_}++for map P,@k;my%s=map{($_,grep$u{$_}==1,P)[0,1]}@k;$S{J@p}={%s};push@q,map[$$h{$_},@p,$_],keys%$h}}for(@I){my(@p,@s);for my$i(@$_){push@s,$S{J@p}{$i};push@p,$i}print J(@p),"\t",J(@s),$/}' < ~/colindean.categories.problem
Nonbillable:Email
Nonbillable:Training:Video
Nonbillable:Training:Podcast
Nonbillable:TimeTracking
Nonbillable:Meeting:Standup
Nonbillable:Meeting:Allhands
Away:Holiday
Nonbillable:Email N:E
Nonbillable:Training:Video N:Tr:V
Nonbillable:Training:Podcast N:Tr:P
Nonbillable:TimeTracking N:Ti
Nonbillable:Meeting:Standup N:M:S
Nonbillable:Meeting:Allhands N:M:A
Away:Holiday A:H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment