November 10 2011 by
jamie in
scala |
Not just for in Lift web apps, the lift-json library serves as a useful, fast, and sophisticated method of handling JSON in your Scala projects. In general usage, the lift-json library is pretty smart about serializing/deserializing messages, which are based on case classes. However, under certain circumstances the case classes in question may be indistinguishable, [...]
September 12 2011 by
jamie in
scala |
I’m working on a project where I want to look at the last modified date of a URL for comparative purposes, and decided to come up with a brief method of fetching the headers and parsing it as a java.util.Date. As with many HTTP-related operations, the go-to project here was the awesome Dispatch project, which [...]
June 14 2011 by
jamie in
scala |
Upgrading a few existing sbt-based projects from 0.7.7 to 0.10.0 was relatively straightforward, but came with a few hurdles. One of these was the enabling of Scala compiler options such as -unchecked and -deprecation. Previously these could be declared by creating (or editing) a project definition file in project/build, something like the following: This method [...]
June 6 2011 by
jamie in
scala |
Scala’s pattern matching is much touted as a killer feature, and generally easy and convenient to use, but due to type erasure one needs to be somewhat careful with typed collections. Check out the following bit of code: It’s tempting to say, “this worked,” and move along, but consider the following similar code where we [...]
May 26 2011 by
jamie in
scala |
The Scala RichString class provides some nice hooks for string manipulation beyond those provided by java.lang.String, including a capitalize method that returns a Java String with the first letter up-cased. For whatever, reason, an “uncapitalize” equivalent is not defined to downcase the first character. Using implicit conversions, one can relatively straightforwardly add such a method [...]
May 24 2011 by
jamie in
scala |
Determining local IP address is easy, but determining MAC address, and subnet mask in Java has always been one of those hairy problems that sends me Googling. Using some of those same Java utilities, we can add a few Scala-isms and shorten the whole thing up significantly. To get the IP address we can just [...]
May 16 2011 by
jamie in
scala |
Ah, the dreaded “first post”. Gotta put something. Ideally I’d dive right in and offer up a useful chunk of info, but I’d like to get something showing on the site so here it is. Soon you’ll see my own unique take on things I’m picking up as I work with and better learn Scala, [...]