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 `uname` in | |
"Linux") | |
export DOCKER_HOST="localhost" | |
#scala -e "println(sys.env(\"DOCKER_HOST\"))" | |
;; | |
"Darwin") | |
if hash docker-machine 2>/dev/null; then | |
export DOCKER_HOST=`docker-machine ip default` | |
#scala -e "println(sys.env(\"DOCKER_HOST\"))" | |
else |
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
# Install release | |
./configure | |
make | |
make check | |
sudo make install | |
sudo ldconfig /usr/local/lib | |
# confirm install | |
protoc --version |
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._, concurrent.ExecutionContext.Implicits.global, concurrent.duration._ | |
case object CreateChild | |
case object GetChildren | |
case object GetParent | |
case class Message(str:String, forward:Boolean=false) | |
class ChildActor extends Actor { | |
def receive = { | |
case msg: String => println(s"${context.self.path.name}: $msg") |
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.JavaConversions._ | |
object ScalaSample { | |
def main(args: Array[String]) { | |
val rand = new java.util.Random() | |
final val N = Integer.valueOf(args(0)) | |
var list = new java.util.ArrayList[Double](N) | |
for (i <- 0 until N) { | |
list.add(rand.nextDouble) | |
} |
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.util.*; | |
class JavaSample { | |
public static void main(String [] args) { | |
Random rand = new Random(); | |
final int N = Integer.valueOf(args[0]); | |
List<Double> list = new ArrayList<Double>(N); | |
for (int i = 0; i < N; i++) { | |
list.add(rand.nextDouble()); | |
} |
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 breeze.linalg._ | |
def generateMat(n: Int): DenseMatrix[Double] = { | |
val mat = DenseMatrix.zeros[Double](n,n) | |
for (k <- 0 until n) { | |
var rv = DenseVector.ones[Double](n) | |
rv = rv*math.random | |
rv(k) = rv(k)*(k+1) | |
mat(k,::) := rv.t | |
} |
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 numpy import linalg | |
import numpy as np | |
import time | |
""" This will generate a random NxN invertible matrix [1] """ | |
def generate_mat(n): | |
mat = list() | |
for k in range(n): | |
rv = np.linspace(1,1,n) | |
rv = rv*np.random.random(n) |
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 BSTNode(payload: Int, left: Option[BSTNode] = None, right: Option[BSTNode] = None) | |
object Treeutils { | |
def inOrder(root: Option[BSTNode]): List[Int] = root match { | |
case None => List() | |
case Some(BSTNode(payload, left, right)) => inOrder(left) ::: List(payload) ::: inOrder(right) | |
} | |
} | |
scala> val tree = BSTNode(10,Some(BSTNode(8,Some(BSTNode(7,Some(BSTNode(6,None,None)),Some(BSTNode(7,None,None)))),Some(BSTNode(9,None,None)))),Some(BSTNode(11,None,None))) |
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
class Animal(object): | |
def __init__(self, *args, **kwargs): | |
print "Animal args", args | |
print "Animal kwargs", kwargs | |
print "Animal name", kwargs['name'] | |
class Dog(Animal): | |
def __init(self, *args, **kwargs): | |
super(Dog, self).__init__(*args, **kwargs) | |
self.name = 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
object `map` { | |
def main (args: Array[String]) { | |
val start = System.nanoTime | |
println("\n(Map) multiplying 20 million elements by 2") | |
val dbls = (1L to 20000000L).map(_*2) | |
//val dbls = (1L to 20000000L).toArray.map(_*2) | |
//val dbls = (1L to 20000000L).toVector.map(_*2) | |
//val dbls = (1L to 20000000L).par.map(_*2) | |
println("(Reduce) sum: %d".format(dbls.sum)) |