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._ | |
import java.util.zip._ | |
import scala.io.Source | |
var in = new GZIPInputStream(new FileInputStream("test.gz")) | |
// write setup in different objects to close later properly (important for big files ) | |
var fos = new FileOutputStream("test2.gz") | |
var gzos = new GZIPOutputStream( fos ) | |
var w = new PrintWriter(gzos) |
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 org.rocksdb._ | |
import org.rocksdb.util.SizeUnit | |
import scala.collection.JavaConversions._ | |
// build.sbt | |
// name := "RocksDB" | |
// version := "0.1" | |
// scalaVersion := "2.12.0" | |
// libraryDependencies += "org.rocksdb" % "rocksdbjni" % "5.0.1" |
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 akka.actor._ | |
import akka.actor.ActorLogging | |
import akka.actor.ActorSystem | |
import akka.stream._ | |
import akka.stream.actor.ActorSubscriberMessage._ | |
import akka.stream.actor._ | |
import akka.stream.scaladsl._ | |
import akka.{ NotUsed, Done } | |
import scala.io.Source |
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
//inspired by http://www.michaelpollmeier.com/2018/12/10/checksum-files-scala | |
import java.io.File | |
import java.nio.file.Files | |
import java.security.{DigestInputStream, MessageDigest} | |
import scala.collection.JavaConverters._ | |
def md5(roots: File*): String = { | |
val md = MessageDigest.getInstance("MD5") | |
roots.foreach { root => |
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
// from https://biercoff.com/easily-measuring-code-execution-time-in-scala/ | |
def time[R](block: => R): R = { | |
val t0 = System.nanoTime() | |
val result = block // call-by-name | |
val t1 = System.nanoTime() | |
println("Elapsed time: " + (t1 - t0) + "ns") | |
result | |
} |
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 javax.crypto._ | |
import javax.crypto.spec._ | |
import java.util.Base64 | |
val message= "Hello" | |
val secret = "eGkmaYd3PE9x3Z221x7b2nXmJ7ACGrjf" | |
val ivString = "0123456789012345" | |
val ciper: Cipher = Cipher.getInstance("AES/CBC/PKCS5Padding") |
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 | |
set -e | |
set +u | |
get_script_dir () { | |
SOURCE="${BASH_SOURCE[0]}" | |
# While $SOURCE is a symlink, resolve it | |
while [ -h "$SOURCE" ]; do | |
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | |
SOURCE="$( readlink "$SOURCE" )" |
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 akka.actor._ | |
import akka.actor.ActorLogging | |
import akka.actor.ActorSystem | |
import akka.stream._ | |
import akka.stream.actor.ActorSubscriberMessage._ | |
import akka.stream.actor._ | |
import akka.stream.scaladsl._ | |
import akka.{ NotUsed, Done } | |
import akka.util.ByteString | |
import java.io._ |
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
# http://www.sequentix.de/gelquest/help/distance_measures.htm | |
bdist <- function( x, y , method ){ | |
a <- sum( x == 1 & y == 1) | |
b <- sum( x == 1 & y == 0) | |
c <- sum( x == 0 & y == 1) | |
d <- sum( x == 0 & y == 0) | |
switch(method, | |
tanimoto = (a+d)/(a+2*(b+c)+d), |
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
/* | |
build.sbt | |
name := "AkkaStreamTemplate" | |
version := "0.1-SNAPSHOT" | |
scalaVersion := "2.12.2" | |
libraryDependencies ++= { | |
Seq( |
NewerOlder