Profile cover photo
Profile photo
Harold Lee
Harold's posts

Post has attachment
Mac dev software
New laptop day... means time to take stock of what I actually use. Applications 0xED 1Password Aquamacs Android SDK Arduino Atom Audacity Blue Jeans Chicken of the VNC Chrome CrashPlan Dia Dropbox Eclipse Firefox Flux GIMP HandBrake IntelliJ IDEA KeePass Li...

Post has attachment
Play: return gzipped bytes
Suppose you have an InputStream of bytes which are gzipped CSV data, e.g. coming from disk or over the network. You can return the data without decompressing it in Play by setting the Content-Encoding to indicate that the data is already gzipped. val gzipDa...

Post has attachment
Scala's MultiMap
Creating: import collection.mutable._
val mm = new HashMap[String,Set[Long]] with MultiMap[String,Long] Not intuitive that key/value pairs would clobber other entries with the same key: scala> mm + (("a", 1)) + (("a", 2))
res2: scala.collection.mutable.Map[...

Post has attachment
Debugging the Scala compiler
The -Xprint:parser will show the parser output, the rest of the options enable debugging via port 1773 (configure your IDE to talk to localhost:1773 as a remote application). ant
build/pack/bin/scala -Xprint:parser -J-Xdebug -J-Xrunjdwp:transport=dt_socket,...

Post has attachment
See what a Scala for comprehension expands into...
Run the REPL via scala -Xprint:parser and then try out your code.

Post has attachment
Adding to a running chain of shell commands
A lot of the time we chain together commands so that the chain stops if any of the commands fails: command1 && command2 && command3 But what if you start command1 and you want to add the rest of the chain without cancelling command1 (which takes a long time...

Post has attachment
Limiting the heap size with Haskell's cabal
First, add "GHC-Options: -rtsopts" to the .cabal file, to declare at compile/link time that runtime parameters can be passed on the command line: Executable progname
Main-Is: Main.hs
Build-Depends: haskell2010, containers, multimap, matrix, ...

Post has attachment
Haskell sparse matrices and vectors
Install the Math.LinearAlgebra.Sparse module: cabal install sparse-lin-alg And some simple code to try it out: import Data.Ratio as R
import Math.LinearAlgebra.Sparse as S

-- you could also import Math.LinearAlgebra.Sparse.Vector as V
-- but those function...

Post has attachment
Use a key to remove duplicate records
If you want to remove duplicate records based on some key field (rather than using toSet), you can use groupBy to find the duplicates and then do some kind of merge/choice to wind up with one value per group. implicit class UniqueBySupport[T](in: Iterable[T...

Post has attachment
Yesod notes
For the Yesod web framework I found that I needed to add a dependency on data-default-class to the project-name.cabal file (just below the data-default line works nicely) or else it would fail to compile the default project. Here's the error I get without t...
Wait while more posts are being loaded