Skip to content

Instantly share code, notes, and snippets.

@shlomif
Created April 28, 2014 22:03
Show Gist options
  • Save shlomif/11385356 to your computer and use it in GitHub Desktop.
Save shlomif/11385356 to your computer and use it in GitHub Desktop.
Equivalent Perl+Shell and Ruby One-Liners (For learning Ruby)
C=50 perl -plE 's/^[^\[]+//;$_=substr($_,0, $ENV{C});' < fc-solve-pseudo-dfs.log.txt | uniq -c | perl -plE 's/\d\K /\t\t/'
C=50 ruby -lne 'BEGIN{$C=0}; sub(/^[^\[]+/,""); $_= $_[0,ENV["C"].to_i]; $P ||= ""; f = lambda { printf("%10d\t\t%s\n", $C, $P) if$C>0; $P=$_;$C=1; }; if ($P != $_) then f.call() ;else $C += 1 end ; END{ f.call()}' < fc-solve-pseudo-dfs.log.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment