Skip to content

Instantly share code, notes, and snippets.

View cedricbastin's full-sized avatar
🇨🇭
Grüezi Schwiiz

Cédric Bastin cedricbastin

🇨🇭
Grüezi Schwiiz
View GitHub Profile
def diff(xs: List[Float]): List[Float] = {
lazy val average = xs.foldRight((0.0f, 0))((c, acc) => (acc._1 + c, acc._2 + 1))
val avg = average._1 / average._2
xs.map(_ - avg)
}
def diff2(xs: List[Float]): List[Float] = {
val nil = (0.0f, 0, ((avg: Float) => Nil: List[Float]))
val average = xs.foldRight(nil){ (c, acc) =>
(acc._1 + c, acc._2 + 1, (avg: Float) => (c - avg) :: acc._3(avg))
@acolyer
acolyer / service-checklist.md
Last active July 10, 2024 05:13
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@drexin
drexin / Macros.scala
Last active October 27, 2016 09:41
macros to get current file and line, inspired by ruby's __FILE__ and __LINE__
import java.io.File
import language.experimental.macros
import scala.reflect.macros.Context
object Macros {
def LINE: Int = macro lineImpl
def lineImpl(c: Context): c.Expr[Int] = {
import c.universe._