Mapping SharePoint to a Windows Drive

Use the “net use” command to map SharePoint to a local drive. You need local network access to SharePoint, so you either need to be in the office or connected via VPN.

net use DRIVE: \\SHARE_POINT_HOST@ssl PASSWORD /user:USERNAME

Excluding Folders in Play Framework 2.2 dist

We have a Play Framework 2.2 application that uses Gulp to optimize the public files. Gulp uses Node.js and it creates a public\node_modules directory. We don’t need the node_modules directory at runtime so we want to remove it when running the Play “dist” command.

1. In build.sbt, add the following lines.

mappings in (Compile, packageBin) ~= { _.filterNot { case (_, name) =>
	  name.startsWith("public\\node_modules")
}}

packageBin is the task that creates the project JAR under Compile scope. mappings are the files used during compilation and packaging. We filter out all the files that are under “public\node_modules”.

2. We also want to to remove the share folder. So we added the following lines in build.sbt as well.

doc in Compile <<= target.map(_ / "none")

Await Scala Futures

Here’s Scala example code that creates 100 Futures and waits for all of them to complete. This is using the global ExecutionContext.

import scala.concurrent.{Future, Await, future}
import scala.concurrent.duration.Duration
import scala.concurrent.ExecutionContext.Implicits.global

object WaitForAllFutures extends App {

    val futures = (1 to 100).map { i =>
      future {
        Thread.sleep(5000)
        println(s"Future $i done.")
      }
    }

    Await.result(Future.sequence(futures), Duration.Inf)
}