Skip to content

Instantly share code, notes, and snippets.

View oluies's full-sized avatar

Örjan Lundberg oluies

  • Sweden
  • 03:04 (UTC +02:00)
  • X @oluies
View GitHub Profile

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
@bfritz
bfritz / after.csv
Last active August 8, 2017 12:34
rapture-csv in Ammonite REPL
territory_id first_name last_name email employee_id
XMOWSM54 Peter Alexander palexander0@unesco.org E00QTOF
XMRNBM47 Samuel Lopez slopez1@163.com E00UBFA
XMOWMF87 Elizabeth Stone estone2@usatoday.com E00WDYK
XMZWPW22 William Carroll wcarroll3@odnoklassniki.ru E00VDYQ
XMOWRW46 Carolyn Little clittle4@ox.ac.uk E00HUPR
XMZNDX26 Marilyn Robinson mrobinson5@wired.com E00ZJGS
XMZNAI68 Christopher Rogers crogers6@posterous.com E00DCHF
XMONCD74 Anthony Allen aallen7@flickr.com E00ACEQ
XMRNMD81 Martin Baker mbaker8@hatena.ne.jp E00DKRZ
@andypiper
andypiper / basic-recipes.md
Last active May 21, 2025 15:12
Twitter API recipes for twurl +jq, and other useful Twitter code snippets and tools
@deanwampler
deanwampler / GraphFramesExample.snb
Created March 4, 2016 13:03
Databrick's Python example for the new GraphFrame API ported to Scala and Spark Notebook
{
"metadata" : {
"name" : "GraphFramesExample",
"user_save_timestamp" : "1970-01-01T01:00:00.000Z",
"auto_save_timestamp" : "1970-01-01T01:00:00.000Z",
"language_info" : {
"name" : "scala",
"file_extension" : "scala",
"codemirror_mode" : "text/x-scala"
},
@rjsvaljean
rjsvaljean / TypedPipelineComposition.scala
Last active February 8, 2016 19:44
Implicit context passing between stages of a pipeline with shapeless
package com.xdotai
import shapeless._
import shapeless.ops.hlist.{Prepend, Align, Remove}
object TypedPipelineComposition {
import ShapelessExt._
@cvogt
cvogt / breakout.scala
Last active January 19, 2017 11:20
Scala collections breakOut
// a List isn't a Map
scala> val x: Map[Int,Int] = List(1,2,3).map(i => i -> i)
<console>:16: error: type mismatch;
found : List[(Int, Int)]
required: Map[Int,Int]
val x: Map[Int,Int] = List(1,2,3).map(i => i -> i)
^
// first create List, then create Map. Intermediate collection overhead
scala> val x: Map[Int,Int] = List(1,2,3).map(i => i -> i).toMap
x: Map[Int,Int] = Map(1 -> 1, 2 -> 2, 3 -> 3)
@andershammar
andershammar / install-apache-zeppelin-on-amazon-emr.sh
Last active October 9, 2018 03:31
Bootstrap script for installing Apache Zeppelin on an Amazon EMR Cluster. Verfied on Amazon EMR release 4.x.
#!/bin/bash -ex
if [ "$(cat /mnt/var/lib/info/instance.json | jq -r .isMaster)" == "true" ]; then
# Install Git
sudo yum -y install git
# Install Maven
wget -P /tmp http://apache.mirrors.spacedump.net/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
sudo mkdir /opt/apache-maven
sudo tar -xvzf /tmp/apache-maven-3.3.3-bin.tar.gz -C /opt/apache-maven
@klenwell
klenwell / websphere.yml
Last active July 4, 2019 18:20
Ansible Playbook to Install WebSphere MQ on Debian Server
#
# This playbook assumes the WebSphere MQ file provided by IBM has already been
# downloaded to a specific directory (target.wd) on the server.
#
# ${target.wd} is a variable representing the working directory on the target
# server the MQ client will be installed.
#
# Note: Although this playbook is designed to be able to be run independently,
# it is in fact part of a longer playbook and therefore may have some other
# unexpected dependencies not reflected here.
package inception.commands;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import javax.ws.rs.client.Entity;
import org.mockito.ArgumentMatcher;
public class UnfuckEntity extends ArgumentMatcher<Entity<?>> {
@m4rw3r
m4rw3r / header.rs
Last active January 13, 2016 06:19
http.rs: Simple HTTP-library for Rust
use std::fmt;
use std::ascii::StrAsciiExt;
#[deriving(Clone,Eq)]
pub enum HeaderName {
Accept,
AcceptCharset,
AcceptEncoding,
AcceptLanguage,
Age,