View Advanced-FP-with-Scala.md

Advanced Functional Programming with Scala - Notes

Copyright © 2016-2017 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
View Mappable.scala
object Mappable {
implicit class ToMapOps[A](val a: A) extends AnyVal {
import shapeless._
import ops.record._
def toMap[L <: HList](implicit
gen: LabelledGeneric.Aux[A, L],
tmr: ToMap[L]
): Map[String, Any] = {
val m: Map[tmr.Key, tmr.Value] = tmr(gen.to(a))
View company-ownership.md

Who pays when startup employees keep their equity?

JD Maturen, 2016/07/05, San Francisco, CA

As has been much discussed, stock options as used today are not a practical or reliable way of compensating employees of fast growing startups. With an often high strike price, a large tax burden on execution due to AMT, and a 90 day execution window after leaving the company many share options are left unexecuted.

There have been a variety of proposed modifications to how equity is distributed to address these issues for individual employees. However, there hasn't been much discussion of how these modifications will change overall ownership dynamics of startups. In this post we'll dive into the situation as it stands today where there is very near 100% equity loss when employees leave companies pre-exit and then we'll look at what would happen if there were instead a 0% loss rate.

What we'll see is that employees gain nearly 3-fold, while both founders and investors – particularly early investors – get dilute

View scala-add-compiler-plugin.gradle
apply plugin: 'application'
apply plugin: 'scala'
repositories {
mavenLocal()
mavenCentral()
}
mainClassName = 'PushkaTest.MainApp'
View lecture1.R
### Regression Example
f = function(x) {
0.1 * cos(x)^2 + 0.25 * sin(x)^(3)
}
regressionData = data.frame(rnorm(5000), sd = 5)
regressionData[,2] = f(regressionData[,1]) + rnorm(5000, sd = 0.1)
names(regressionData) = c("x", "y")
View SafeEq.scala
import scala.language.experimental.macros
import scala.reflect.macros.Context
/**
* you can try this in the REPL even
*/
object SafeEq {
/**
* eqv(1, "foo") won't compile
View dfs-bfs-non-recursive.js
/**
* Depth-first and Breadth-first graph traversals.
*
* In this diff we implement non-recursive algorithms for DFS,
* and BFS maintaining an explicit stack and a queue.
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
* MIT Style license
*/
View jargon.md

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

View EbDockerPlugin.scala
import java.nio.charset.Charset
import java.text.SimpleDateFormat
import java.util.Date
import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalkClient
import com.amazonaws.services.elasticbeanstalk.model.{UpdateEnvironmentRequest, S3Location, CreateApplicationVersionRequest}
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.s3.model.Region
import com.typesafe.sbt.packager.docker.DockerPlugin
import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport.{Docker, dockerExposedPorts}
View Scala Activity
package com.example.jeremybell.myapplication
import android.app.Activity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
class MyActivity extends Activity {
override def onCreate(savedInstanceState: Bundle): Unit = {
super.onCreate(savedInstanceState)