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
> runMain ammonite.repl.Repl | |
[info] Running ammonite.repl.Repl | |
Loading Ammonite Repl... | |
@ load.ivy("com.chuusai" %% "shapeless" % "2.1.0") | |
@ import shapeless._ | |
import shapeless._ | |
@ 1 :: "lol" :: List(1, 2, 3) :: HNil |
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
// | |
// Apply extends the Functor Typeclass by adding a method `ap` which | |
// is similar to `map` from Functor in that it takes a functor that | |
// that has a function in it and another functor and extracts that | |
// function from the first functor and then maps it over the second | |
// one | |
// | |
// Alternatively, you can say `ap` lets you apply a function in a | |
// context to a value in a context | |
// |
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
// | |
// Foldable | |
// - fold a data structure | |
// - usually, fold F[A] given a Monoid[A] | |
// | |
trait Foldable[F[_]] { self => | |
def foldRight[A, B](fa: F[A], z: => B)(f: (A, => B) => B): B | |
def foldLeft[A, B](fa: F[A], z: B)(f: (B, A) => B): B = { |
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
language: scala | |
scala: | |
- 2.10.4 | |
jdk: | |
- oraclejdk8 | |
- oraclejdk7 | |
services: mongodb | |
script: | |
- sbt scoverage:test | |
- sbt coveralls |
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.language.higherKinds | |
import scala.reflect.ClassTag | |
import scala.language.implicitConversions | |
trait Data[D[_]] extends Serializable { | |
def map[A, B: ClassTag](d: D[A])(f: A => B): D[B] | |
def flatMap[A, B: ClassTag](d: D[A])(f: A => Iterable[B]): D[B] |
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.language.experimental.macros | |
import scala.reflect.macros.whitebox | |
class FreeMacros(val c: whitebox.Context) { | |
import c.universe._ | |
def smartName(name: String): String = ( | |
name.toList match { | |
case h :: t => h.toLower :: t | |
case Nil => Nil |
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
extern crate deeplearn; | |
extern crate matrix; | |
use deeplearn::Graph; | |
use deeplearn::op::{MatMul, Relu}; | |
fn main() { | |
let ctx = matrix::Context::new(); | |
// Setup the graph |
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
Dataset: COREL subset ( 7 classes, 100 images per class => 7*100 = 700 jpgs ) | |
COREL: https://sites.google.com/site/dctresearch/Home/content-based-image-retrieval | |
Training Test Ratio: 80-20 | |
Equal number of true & false samples ie. train on 80 dinos & 80 random non-dinos out of 700-100 = 600 non-dinos. | |
So training sample size = 80 + 80 = 160 | |
Test sample = 20 dinos + 20 non-dinos | |
Train 1 SVM classifier per class => 7 SVM classifiers |
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 DiffieHellmanMerkle { | |
import java.math.BigInteger | |
import scala.language.implicitConversions | |
import scala.util.Random | |
def main(args: Array[String]): Unit = | |
println( | |
diffieHellmanMerkle(generator = 3, modulus = 17, alicePrivateKey = 54, bobPrivateKey = 24) | |
) |
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
//send messages via Pusher API in play 2.4 | |
import play.api.libs.json.{ Writes, Json } | |
import play.api.libs.ws.{ WSResponse, WSClient } | |
import play.api.libs.ws.ning.NingWSClient | |
import java.security.MessageDigest | |
import java.math.BigInteger | |
import javax.crypto.Mac | |
import javax.crypto.spec.SecretKeySpec | |
import scala.concurrent.{ ExecutionContext, Future } |
OlderNewer