Skip to content

Instantly share code, notes, and snippets.

@aaronlevin
aaronlevin / events.hs
Last active Jun 9, 2020
LambdaWorld 2016 & Typelevel Summit 2017 (Copenhagen): Type-Level DSLs // Typeclass induction
View events.hs
-- Our goal is to create a type describing a list of events. This is our
-- type-level DSL.
-- We will then use typeclass resolution to "interpret" this type-level DSL
-- into two things:
-- 1. A comma-separated list of events
-- 2. A method that, when given an event name and a payload, will try to parse
-- that event type with the payload. A form of dynamic dispatching
--
-- To model a list of types we will use tuples. You can imagine the list of
-- types "Int, String, Char" to look like:
View Applied-FP-with-Scala.md

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
@acolyer
acolyer / service-checklist.md
Last active Oct 13, 2020
Internet Scale Services Checklist
View service-checklist.md

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?
@vrischmann
vrischmann / .credentials
Last active Aug 19, 2020
Running SBT with a Nexus proxy with authentication
View .credentials
realm=Sonatype Nexus Repository Manager
host=nexus.company.com
user=admin
password=admin123
@sindresorhus
sindresorhus / post-merge
Last active Oct 17, 2020
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
View post-merge
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@torgeir
torgeir / builder.scala
Last active Dec 21, 2015
Type safe scala builder, with required arguments, without a build()!
View builder.scala
object BuilderTest {
class NAME_WAS_SET
case class Person(name: String, age: Option[Int])
case class PersonBuilder[NAME_NOT_SET](name: Option[String], age: Option[Int]) {
def withName(name: String) = new PersonBuilder[NAME_WAS_SET](Some(name), age)
def withAge(age: Int) = new PersonBuilder[NAME_NOT_SET](name, Some(age))
}
View instruction.sh
sudo gem install keydown # optional, only needed if you update the markdown.
git clone git@github.com:retronym/talks.git
git clone -b topic/play-keydown git@github.com:retronym/replhtml.git && cd replhtml
sbt -Dkeydown.root=$PWD/../talks/scala-2.10 run
open http://localhost:8080
@okapies
okapies / Id.scala
Created May 27, 2012
How to implement case class manually. (for Scala 2.9.2 final)
View Id.scala
import scala.runtime.ScalaRunTime
/**
* A sample code to implement a customized case class manually (for Scala 2.9.2 final).
*
* Id has two properties: name and displayName. 'displayName' has default value that
* is same value as 'name'.
*/
class Id private ( // make primary constructor not to be accessible. (standard case class can do)
You can’t perform that action at this time.