Today I wanted to add one of my Github repositories to a sbt project. I was working on my Windows laptop. I setup the following Build.scala file and placed it in the project directory under the root directory of my sbt project: Continue reading
Month: October 2014
Generating a large test file with Scala like the Linux dd command
I was writing functionality to merge download chunks yesterday. This functionality takes a file that is downloaded in chunks and mergers these chunks back into a single file. Writing the test class I did not want my test to depend on downloading a file in chunks, so I needed a way to quickly generate a number of chunks that could be merged. Under Linux the dd command is available that generates a file of a given size that contains random contents. I wrote a small helper class that does exactly this, with the extra twist that it splits the file into a number of chunks. Continue reading
Composable behavior in Scala
I continue to be amazed by what can be done with Scala. Once you start to understand the simplicity and beauty of coding in Scala it is really easy and fun. As part of my learning exercise I am implementing a multi threaded downloader. One part of the solution is a splitter. It takes a file size and splits it up into a number of chunks that can be downloaded in parallel. I have implemented a Chunk, that holds information about a chunk, as a case class and created a trait ChunkDownload that can be bolted on to this case class at runtime. This is so called composable behavior which adds functionality to the case class. Continue reading
Which open source license to choose?
I am working on a few projects I would like to release as open source. One of the important things to consider when releasing code as open source is the license to release it under. I think the license should not be an after thought, but a careful consideration up front before you commit your first code. What if you release it on Github and someone likes it and decides to contribute. Changing a license after accepting contributions is not trivial. Continue reading
Is the HTTP header Last-Modified always in GMT?
I needed to parse the HTTP header Last-Modified to a Java Date. When I tried to parse the value of the header “Mon, 02 Jun 2008 15:30:42 GMT” it threw an exception java.text.ParseException: Unparseable date. After playing around with the code a bit I figured out I needed to add TimeZone and Locale to get the value to parse correctly. Continue reading
Calculating the MD5 checksum of a file under Windows
I was working on my Windows laptop and needed to calculate the MD5 checksum of a file. Under Linux no problem, but how do you do that under Windows? As always Google is your friend. I found the Microsoft File Checksum Integrity Verifier tool on the Microsoft website. Easy to install and use. Continue reading
Using scala-logger
Today I was adding logging to one of my projects. I decided to use scala-logger. I added scala-logger dependency to the build.sbt, excuted my test class and got the following error in the Eclipse console output:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
“value ? is not a member of akka.actor.ActorRef”
I was trying to use a Future in Akka today and got the following error message:
value ? is not a member of akka.actor.ActorRef
It turns out you have to import the akka.pattern.ask to use ‘?’. There is a implicit conversion from ActorRef to AskableActorRef.
So add the following import and you should be set to go (take note that ask does not start with a capital:
import akka.pattern.ask
Aaahhhhh, changing the shell defaults of Git Bash under Windows
Have you been frustrated by the default window shell settings of Git Bash under Windows? I have. Changing the settings of the Git Bash window directly using properties does not work. Today it bugged me enough that I decided to spend some time to fix it. Continue reading
Getting UPC Horizon TV to work on Linux
Who still uses Microsoft Silverlight? UPC… They use the Silverlight plugin to stream TV and handle DRM. Okay, that’s nice, but how do you get Silverlight to work under Linux? It turns out it is a few easy steps using Pipelight which brings support for Silverlight to Firefox and Chrome under Linux. Continue reading