Ruby One Liners

From EggeWiki

Find duplicate class files in multiple jars. Tip: run this in your JBoss lib directory.

<geshi lang="ruby">

  1. If a class file has a different size in a different jar file you might have a problem on your hands

find . -type f -name "*.?ar" -print -exec jar tvf {} \; \ | ruby -ne 'BEGIN{ $h={} }; puts $_ if $_ =~ /.*.jar$/; if $_ =~ /([0-9]+).{31}(.*)/ then $h[$2] ||= $1; puts $2 + " size " + $1 + " != " + $h[$2] if $h[$2] != $1; end ' </geshi>

Parse Awstats html output. <geshi lang="ruby"> ruby -ne 'if $_ =~ /href="http:\/\/www.theeggeadventure.com\/(.*?)".*?([0-9]+).*?([0-9.]+) KB/ then puts "#{$1}\t#{$2}\t#{$3}" end ' \

< awstats.pl | putclip

</geshi>