Skip to content

Instantly share code, notes, and snippets.

View Krasnyanskiy's full-sized avatar

Sasha Krasnyanskiy

  • Cupertino, California
View GitHub Profile
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
// Reduction: We can sum all the elements
// with the usual recursive schema
def sum(xs: List[Int]): Int = xs match {
case Nil => 0
case y :: ys => y + sum(ys)
}
// But this can be abstracted out using 'reduceLeft'
// That will perform these operations LINKING to the left
def sum(xs: List[Int]) = (0 :: xs) reduceLeft ((x, y) = x + y)
class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
POST /rest/login HTTP/1.1
Content-Type: application/x-www-form-urlencoded
User-Agent: Jersey/2.13 (HttpUrlConnection 1.7.0_79)
Host: localhost:8085
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Length: 41
j_username=superuser&j_password=superuserGET /rest_v2/users HTTP/1.1
Accept: application/json
@Krasnyanskiy
Krasnyanskiy / gist:fdbd6c28617e63eab674
Last active September 18, 2015 11:05 — forked from skroah/gist:9c22697521626c7b388b
Reactive Systems Design

##Reactive System Design Links

#Articles and Papers

scalac -Xshow-phases

    phase name  id  description
    ----------  --  -----------
        parser   1  parse source into ASTs, perform simple desugaring
         namer   2  resolve names, attach symbols to named trees
packageobjects   3  load package objects
         typer   4  the meat and potatoes: type the trees
        patmat   5  translate match expressions
def f[A: B, C](a: A)
class B
// From Spray Framework
implicit def fromStatusObject[T](tuple: (StatusCode, T))(implicit ev: Marshaller[T]) = ???
implicit def fromStatusObject[T: Marshaller](tuple: (StatusCode, T)) = ???