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
Uncategorized
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
Adding the latest release of Akka to an SBT project
A quick note how to create a SBT project with the latest release of Akka.
Create a build.sbt file:
name := "ScalaAkkaTest" organization := "<Your organisation name>" version := "0.1.0-SNAPSHOT" scalaVersion := "2.11.2" resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.3.6"
Aaaahhhh I just deleted a branch in Git before merging it back into development
Okay I just deleted a feature branch before merging it back into the development branch. What to do? Lucky I had already committed the changes to the feature branch which made recovery very simple. Continue reading