Skip to content

Instantly share code, notes, and snippets.

View carl297r's full-sized avatar

Carl Livermore carl297r

View GitHub Profile
import java.io.File
csvwrite(new File("x-matrix.csv"),X)
val X3 = csvread(new File("x-matrix.csv"))
@carl297r
carl297r / keybase.md
Created October 28, 2017 16:42
Keybase proof

Keybase proof

I hereby claim:

  • I am carl297r on github.
  • I am carl297r (https://keybase.io/carl297r) on keybase.
  • I have a public key whose fingerprint is 877C C76E 8B3D 233F 14F2 8788 5A81 D87C 7BBD CC83

To claim this, I am signing this object:

@carl297r
carl297r / TransMapStream
Last active August 29, 2015 14:07
Transfrom Map[K, Stream[R]] into Stream[Map[K,R]]. Then operate over the new combined Stream to produce a Stream of sum products.
// Here is my dummy row data for a single commodity. Only has 2 things, price and holding but yours will have more like date.
// I left out date because it was needed to calc sum product but not hard to include.
case class Row(price: Double, holding: Double)
// This function is generates my stream of dummy row prices and holdings
def RowStream(start: Row): Stream[Row] = start #:: RowStream(Row(start.price+1, start.holding + 2))
// Here are my streams for NG, CL & AG
val ng = RowStream(Row(1,1))
val cl = RowStream(Row(100,10))
// See https://gist.github.com/carl297r/10019568
@carl297r
carl297r / PersistedGameOfPingPongWithSnapshots.scala
Last active August 29, 2015 13:58
A game of ping pong using two Akka Actors, persisted using Event Sourcing through Akka Persistence. Adapted from Jonas Bonér's example https://gist.github.com/jboner/9990435 to add Snapshots.
package demo
// Adapted from Jonas Bonér's example https://gist.github.com/jboner/9990435
import akka.actor.{Props, ActorSystem}
import akka.persistence.{EventsourcedProcessor, SnapshotOffer}
object PersistedPingPong extends App {
case object Ball //The Command