Christer Sandberg

Feb 172013

We have started a small project to build a web-ROTI, that is an app that can be used to measure how good your meetings are. After one day of hacking we have a MVP.

Web-ROTI (Return On Time Invested) is a tool to gauge the time spent on meetings and improve them.
ROTI can easily be measured on whiteboard or paper but you are running the risk of getting a biased result when the voters see other votes. In Web-ROTI the vote is given without bias, as a bonus it calculates the average as well.
A vote is a number between 1 and 5
  1. A complete waste of time
  2. Not so good
  3. Break even, my gain is equal to the time spent
  4. Positive
  5. Superb, I could not have used this time better Continue reading »
May 222012

I’ve been hacking up a remote shell for our actor based broadcasting system. It’s a read only shell with commands like cd, ls, stat etc. It uses Akka, Netty and Scala with its parser combinators. I was thinking a bit about how to resolve a path. By resolve I mean how to combine the current path with one provided for one of the commands above and making it absolute. My goals was (as always) to only work with immutable data structures (if possible) and make it as tight as possible. By the way, the path that I’m parsing looks like a regular UNIX path. I.e. /foo/bar/../xyz. Here’s the implementation I chose:

def resolvePath(path: List[String]): List[String] = {
  path match {
    case Nil | ".." :: Nil => Nil // Root
    case x @ _ :: Nil => x // Only one element. Not '..'
    case xs =>
      (xs :\ 0 -> List.empty[String]) { (x, acc) =>
        val (skip, ys) = acc
        if (x == "..") skip + 1 -> ys // An element to skip
        else if (skip == 0) 0 -> (x :: ys)  // Prepend element to list
        else skip - 1 -> ys // Decrement skip count
      }._2 // Return path

As you can see the method takes the path as a list of strings. The path /foo/bar would be the list "foo" :: "bar" :: Nil after it’s been parsed. I use a right fold when building up the resolved path. I could have used a left fold which would have made it a bit tighter, but then I would have to reverse the list when done to get the path elements in the correct order. It wouldn’t be that much of an overhead in most cases but I think that a right fold is more appropriate. Why don’t you show me your implementation? Choose your language of choice.