Skip to content

Instantly share code, notes, and snippets.

View natemurthy's full-sized avatar

Nathan Murthy natemurthy

View GitHub Profile
@natemurthy
natemurthy / linalg_benchmarks.py
Last active August 29, 2015 14:19
linear algebra benchmarks
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)
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
}
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());
}
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)
}
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")
# Install release
./configure
make
make check
sudo make install
sudo ldconfig /usr/local/lib
# confirm install
protoc --version
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
{
"id": "python-app",
"cmd": "python3 -m http.server 8080",
"cpus": 0.5,
"mem": 32.0,
"container": {
"type": "DOCKER",
"docker": {
"image": "python:3",
"network": "BRIDGE",
@natemurthy
natemurthy / build.txt
Created June 13, 2016 04:39
Play dependencies
play-multimodule-demo nate$ sbt test:compile
[info] Loading project definition from /Users/nate/Workspace/github.com/natemurthy/play-multimodule-demo/project
[info] Updating {file:/Users/nate/Workspace/github.com/natemurthy/play-multimodule-demo/project/}play-multimodule-demo-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.typesafe.play/sbt-plugin/scala_2.10/sbt_0.13/2.4.6/jars/sbt-plugin.jar ...
[info] [SUCCESSFUL ] com.typesafe.play#sbt-plugin;2.4.6!sbt-plugin.jar (4806ms)
[info] downloading https://repo1.maven.org/maven2/com/typesafe/play/sbt-routes-compiler_2.10/2.4.6/sbt-routes-compiler_2.10-2.4.6.jar ...
[info] [SUCCESSFUL ] com.typesafe.play#sbt-routes-compiler_2.10;2.4.6!sbt-routes-compiler_2.10.jar (4253ms)
[info] downloading https://repo1.maven.org/maven2/com/typesafe/play/sbt-run-support_2.10/2.4.6/sbt-run-support_2.10-2.4.6.jar ...
[info] [SUCCESSFUL ] com.typesafe.play#sbt-run-support_2.10;2.4.6!sbt-run
curl -X POST http://marathon-master:8080/v2/apps -d @python-app.json -H "Content-type: application/json" | python -m json.tool