Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jehrhardt on github.
  • I am jehrhardt (https://keybase.io/jehrhardt) on keybase.
  • I have a public key ASBvdwoxc5ofY02pksHEurtNDEioiS9KrIJFCqqhURunkwo

To claim this, I am signing this object:

@jehrhardt
jehrhardt / foo.clj
Last active October 29, 2016 07:10
simple clojure spec
(s/def ::bar (s/and int? even? #(> % 1000)))
(s/def ::foo (s/keys :req [::bar]))
(s/valid? ::foo {:bar 10000})
@jehrhardt
jehrhardt / Foo.scala
Last active October 29, 2016 07:05
simple case class
case class Foo(bar: Int)

Setup Mac OS X

Basic instructions on setting up my Mac.

Download and install Java and Virtual Box from Oracle:

Install Homebrew

#! /usr/bin/env bash
# Setup:
# 1. Install latest Java and Virtual Box
# 2. Install Homebrew:
# ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# 3. run script
# curl -L https://gist.githubusercontent.com/jehrhardt/d5d7e364e12e283c8949/raw/install_defaults.sh | sh
# Install Emacs via Homebrew

akka

Basic introduction into the akka framework.

SBT dependency

Declare akka dependency in build.sbt

"com.typesafe.akka" %% "akka-actor" % "2.3.12"

Futures

Dealing with Scala's futures.

Basics

Futures integrate well into the language. We know how to create an Option and Futures should work the same.

import scala.concurrent._

Some(1)

try

Introduction to Try and IO with Scala.

Repeat Either

Either can be used for errors, but requires convention.

case class BlogNotFoundException(message: String) extends Exception(message)

Errors

Dealing with errors in Scala.

for comprehension

Simple foreach

type Blog = Int
type BlogArticle = Int

objects

Objects, classes, traits and case classes

Basics on classes

Use the keyword class

class Foo

val foo = new Foo