This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.IOException; | |
import java.net.URL; | |
import org.apache.commons.io.FileUtils; | |
public class Resource { | |
private static java.net.URLStreamHandler cp = new org.ops4j.pax.url.classpath.Handler(); | |
private final URL url; | |
private final String paths[]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util.implicits | |
object RichConfig extends RichConfig | |
trait RichConfig { | |
import com.typesafe.config.Config | |
import net.ceedubs.ficus.Ficus._ | |
import util.types.Database | |
implicit class RichConfig(config: Config) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.mutable.{ Map, HashMap, Set, MultiMap } | |
// val evictedModuleIDs: Seq[ModuleID] = ... | |
val evicteds: Map[String, Set[ModuleID]] = | |
(new HashMap[String, Set[ModuleID]] with MultiMap[String, ModuleID] /: evictedModuleIDs) { | |
case (acc, m) => | |
val key = s"${m.organization}:${m.name}" | |
acc.addBinding(key, m) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Ctx(_state: State) { | |
val state: State = _state | |
val xt: Extracted = Project.extract(state) | |
val bs: BuildStructure = xt.structure | |
val pr: ProjectRef = ProjectRef(bs.root, bs.rootProject(bs.root)) //i.e.: the root project! | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait EvaluationSupport { | |
import sbt._ | |
protected def fail(errorMessage: String, state: State): Nothing = { | |
state.log.error(errorMessage) | |
throw new IllegalArgumentException() | |
} | |
protected def log(implicit state: State) = state.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def matches(text: String, is: InputStream = System.in): Int = | |
scala.io.Source.fromInputStream(is) | |
.getLines | |
.toStream | |
.map(line => if(line.contains(text)) 1 else 0) | |
.reduce(_ + _) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(row <- sheet.rows if (row.index == index); Cell(cindex, data) <- row.cells) yield { (cindex, data) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io._ | |
val osURL: PartialFunction[Option[String], OutputStream] = { | |
case Some(name) => new java.io.FileOutputStream(new java.io.File(name)) | |
if(name.contains(":")) | |
} | |
val osLocalFile: PartialFunction[Option[String], OutputStream] = { | |
case Some(name) => new java.io.FileOutputStream(new java.io.File(name)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#-*- mode: scala; -*- | |
##### | |
##### NOTE: save this script WITHOUT EXTENSION onto the file system. | |
##### | |
launcher=$(which sbt-launch.jar) | |
if [ -z "$launcher" ] ;then | |
pushd /tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.jcip.annotations.NotThreadSafe | |
import org.cache2k.impl.ClockProPlusCache | |
type ImageType = Array[Byte] | |
class CacheSource(dir: java.io.File) | |
extends org.cache2k.CacheSource[String, ImageType] { | |
import java.nio.file.Files | |
import javax.imageio.ImageIO |