Skip to content

Instantly share code, notes, and snippets.

View jehrhardt's full-sized avatar

Jan Ehrhardt jehrhardt

View GitHub Profile

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