Skip to content

Instantly share code, notes, and snippets.

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

@nadavwr
nadavwr / gist:3184926
Created July 26, 2012 22:15
macro for: val foo: Foo = new Foo(bar)
// val foo: Foo = new Foo(bar)
private[this] def declareRuntime: Tree = {
val runtimeClass = context.mirror.staticClass(classOf[Foo].getName)
ValDef(
Modifiers(),
newTermName("foo"),
TypeTree(runtimeClass.asType),
Apply(
Select(
New(Ident(runtimeClass)),
@nadavwr
nadavwr / androidApp_build.sbt
Created July 15, 2015 18:04
android-sdk-plugin conflicts with sbt-native-packager over 'package-name'
// androidApp/build.sbt
android.Plugin.androidBuild
platformTarget in Android := "android-22"
libraryDependencies += "com.google.android.gms" % "play-services" % "4.3.23"
autoScalaLibrary := false
@nadavwr
nadavwr / pthread.scala
Last active June 8, 2018 11:59
Scala Native pthread attempt
import scala.scalanative.native._
import scala.scalanative.runtime.GC
@extern
@link("pthread")
object pthread {
type pthread_t = Ptr[CStruct0]
type pthread_attr_t = CStruct0
def pthread_create(thread: Ptr[pthread_t], attr: Ptr[pthread_attr_t],
start_routine: CFunctionPtr1[Ptr[Byte], Ptr[Byte]], arg: Ptr[Byte]): CInt = extern

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@nadavwr
nadavwr / .gitpod.Dockerfile
Created May 28, 2020 15:18
GitPod Metals setup
FROM gitpod/workspace-full
USER gitpod
RUN brew install coursier/formulas/coursier
ENV COURSIER_CACHE /workspace/.coursier/cache/v1
RUN cs setup --yes --jvm 14 --apps sbt-launcher,scala,scalafmt,mill,mill-interactive