Skip to content

Instantly share code, notes, and snippets.

@driquelme
driquelme / gist:9c3be40b70f61f849f57
Created May 18, 2015 12:05
Reactively read file with RxScala
trait IO {
case class Chunk(length: Int, bytes: Array[Byte])
def rxReadFilePath(filePath: String, bufferSize: Int):Observable[Chunk] = Observable.create { obs =>
var continue = true
val stream = fileContentStream(new FileInputStream(filePath), bufferSize) takeWhile { chunk =>
chunk.length > 0 && continue }
stream filter { chunk => chunk.length > 0 && continue } foreach {chunk => obs.onNext(chunk) }
Subscription { def unsubscribe = continue = false }
}
@driquelme
driquelme / gist:56014491be396161229d
Created April 14, 2015 13:45
Scala print out memory usage
al mb = 1024*1024
val runtime = Runtime.getRuntime
println("** Used Memory: " + (runtime.totalMemory - runtime.freeMemory) / mb)
println("** Free Memory: " + runtime.freeMemory / mb)
println("** Total Memory: " + runtime.totalMemory / mb)
println("** Max Memory: " + runtime.maxMemory / mb)
@driquelme
driquelme / gist:613588f43b2dd4f3dd55
Created April 7, 2015 20:05
Obtain mondrian.olap.Connection from OlapConnection
val mondrianConnection = olapConnection.unwrap(classOf[mondrian.olap.Connection])

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like: