Saturday, January 4, 2014

Using ruby to explore scalaz

I've been poking around scalaz, and sometimes it's nice to just get a quick overview of the code using some simple ruby. I could write some code using asm to look at the bytecode, but it's usually faster for me to just use ruby on the source. I'm not looking for 100%-complete tested code here, it's more like a very fancy grep.

For example, I was curious about all the places that define functions starting with lift:



And then to read the output, I use a google spreadsheet:



Run with:

find * -name *.scala -type f -print0 | xargs -0 ruby lift.rb | pbcopy

pbcopy is the mac utility that copies stdout to the clipboard, so it's fast to run this from the command line, switch to the spreadsheet, and hit paste.

Thursday, December 19, 2013

Scala IDE worksheet feature - some XML samples

If you haven't played around with the Scala IDE's worksheet feature, it's pretty useful. Here's an example of using it to remind myself of how Scala does XML:



Sunday, September 1, 2013

Combine reference.conf files from a bunch of akka jars

Need to build a reference.conf from a bunch of different Akka jars?  Here's a simple way to do it from the command line:

for i in /Users/james/nexus/sonatype-work/nexus/storage/central/com/typesafe/akka/*/2.2.1/*jar ; do unzip -q -c $i reference.conf ; done > /tmp/reference.conf

That just cats together the contents of all the reference.conf files and puts it in /tmp/reference.conf.

Adjust the paths to fit your version and file locations, of course.