Profile

Cover photo
Harold Lee
61 followers|103,543 views
AboutPostsPhotosVideos

Stream

Harold Lee

Shared publicly  - 
 
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...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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,...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
Flatten a list of optional values in Java 8
Java 8 sticks closer to Haskell than Scala for lists of optionals: you can't just flatMap a function that returns an Optional value and collect all of the values that were present. So I'm finding myself getting the same thing done with filter/map to unpack ...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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[...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
See what a Scala for comprehension expands into...
Run the REPL via scala -Xprint:parser and then try out your code.
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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, ...
1
Add a comment...

Harold Lee

Shared publicly  - 
 
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...
1
Harold Lee's profile photoBarbara A. Hotelling's profile photo
3 comments
 
Thanks. I'm trying to clean up my duplicate photos and was planning to go
through them 1 by 1. I'm also trying to learn Google+.

Love ya,
Mom
Add a comment...

Harold Lee

Shared publicly  - 
 
Find the scripting engines supported by your JVM using Scala
From a Scala REPL: import collection.JavaConverters._
new javax.script.ScriptEngineManager().getEngineFactories.asScala.map { ef => (ef.getEngineName, ef.getNames) }.toMap For me, that gives Map(AppleScriptEngine -> [AppleScriptEngine, AppleScript, OSA], Or...
1
Add a comment...
Basic Information
Gender
Male
Links
YouTube
Other profiles
Contributor to