Skip to content

Instantly share code, notes, and snippets.

Avatar
😘
Taking care of my daugther

Nepomuk Seiler muuki88

😘
Taking care of my daugther
View GitHub Profile
View gist:4340776
private static FloatMatrix multiply(FloatMatrix A, FloatMatrix B, boolean local) throws IOException {
if (A.getColumnDimension() != B.getRowDimension()) {
throw new IllegalArgumentException("Matrix inner dimensions must agree.");
}
CLContext context = JavaCL.createBestContext();
CLQueue queue = context.createDefaultQueue();
int resultLength = A.getRowDimension() * B.getColumnDimension();
Pointer<Float> aPtr = matrixToPointer(A);
@muuki88
muuki88 / MyApp.scala
Created Jul 23, 2016
finagle-01-utils
View MyApp.scala
import com.twitter.app.App
object MyApp extends App {
def main() {
println("Hello, World")
}
}
View MyAppWithFlags.scala
import com.twitter.app.App
object MyApp extends App {
// parses an integer from the "-port" flag.
// Finagle already provides an implicit Flaggable typeclass for Int
// usage: -port 9000
val port = flag[Int]("port", 8080, "port this server should use")
// parses an Env trait. See typeclass below
View temperature_service.thrift
namespace * net.gutefrage.temperature.thrift
/**
* temperature in celisus and timestamp in UTC milliseconds
*/
struct TemperatureDatum {
1: i32 celsius,
2: i64 timestamp
}
View TemperatureServer.scala
import net.gutefrage.temperature.thrift._
import com.twitter.finagle.ThriftMux
// this is the raw implementation with the twitter Future based API
val service = new TemperatureService.FutureIface {
override def add(datum: TemperatureDatum): Future[Unit] = ???
override def mean(): Future[Double] = ???
}
View TemperatureClient.scala
package net.gutefrage
import com.twitter.app.App
import com.twitter.conversions.time._
import com.twitter.finagle.{ThriftMux}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.util.{Await, Future}
import net.gutefrage.temperature.thrift._r
/**
View Dtabs.scala
package net.gutefrage
import com.twitter.finagle.Dtab
/**
* Holds different delegation tables
*/
object Dtabs {
def init(): Unit = {
View Announce.scala
// import flaggable type class
import Env._
// start a service in an environment with
// --env prod
val env = flag[Env]("env", Env.Local, "environment this server runs")
val port = flag[Int]("port", 8080, "port this server should use")
val server = ThriftMux.server
.withLabel("temperature-service")
View TemperatureClient.scala
package net.gutefrage
import com.twitter.app.App
import com.twitter.conversions.time._
import com.twitter.finagle.{ThriftMux}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.util.{Await, Future}
import net.gutefrage.temperature.thrift._r
/**