Skip to content

Instantly share code, notes, and snippets.

@mkows
mkows / intellij-scala-flat-spec.vm
Last active February 24, 2017 11:53
IntelliJ Scala Flat Spec Template (with Matchers, Futures, Mockito)
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.mockito.Matchers.{any, eq => eqq}
import org.mockito.Mockito.{verify, when}
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.mock.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
#set($NAME_WITHOUT_SUFFIX4 = $NAME.length() - 4)
class ${NAME} extends FlatSpec with Matchers with ScalaFutures with MockitoSugar {
@mkows
mkows / intellij-scala-flat-spec-fixture.vm
Last active February 24, 2017 12:01
IntelliJ Scala Flat Spec Template (also with fixture)
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.mockito.Matchers.{any, eq => eqq}
import org.mockito.Mockito.{verify, when}
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.mock.MockitoSugar
import org.scalatest.{FlatSpec, Matchers}
import scala.language.reflectiveCalls

Advanced Functional Programming with Scala - Notes

Copyright © 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
@mkows
mkows / build.sbt
Last active August 4, 2017 12:27
sbt - resolvers are not propagated from dependency library
/*
Resolvers -- specified on child level are not effective / visible on / propagated to parent lib.
// related: https://stackoverflow.com/questions/10727079/how-do-transitive-resolvers-work-with-sbt#23158200
Example with https://github.com/etaty/rediscala that requires custom resolver for rediscala ver. 1.3
Don't forget to make sure that lib is not cached locally, e.g. rm -rf ~/.ivy2/cache/com.etaty.rediscala
*/
@mkows
mkows / stackoverflow_zen.user.js
Last active September 28, 2017 11:29
Make StackOverflow layout less distracting - removes sidebar and notifications
// ==UserScript==
// @name StackOverflow - Zen
// @namespace mkows
// @description Make StackOverflow layout less distracting - removes sidebar and notifications
// @include http://stackoverflow.com/*
// @include https://stackoverflow.com/*
// @version 0.0.2
// ==/UserScript==
// Install steps:
@mkows
mkows / .travis.yml
Created December 18, 2017 14:59
TravisCI: Specify custom MongoDB version
# e.g. for MongoDB 2.6
#
# Follows MongoDB for Ubuntu installation https://docs.mongodb.com/v2.6/tutorial/install-mongodb-on-ubuntu/
# note: `--allow-downgrades` flag for apt-get install may be required
language: scala
scala: 2.11.11
jdk: openjdk8
@mkows
mkows / init-sbt.sh
Last active June 22, 2018 10:28 — forked from maciej/init-scala.sh
Init sbt project
#!/bin/bash
# Usage: init-sbt.sh my-new-project
PROJECT_NAME="$1"
SCALA_VERSION="2.11.6"
SCALATEST_VERSION="2.2.4"
mkdir $PROJECT_NAME
cd $PROJECT_NAME
@mkows
mkows / init-git.sh
Created June 22, 2018 10:50
Initialize git repository in a current dir (with .gitignore, README.md)
#!/bin/bash
# Usage: ./init-git.sh
# NOTE: Run within your project directory
# .gitignore
cat > .gitignore << EOF
target/
.DS_Store
.idea
.idea_modules
@mkows
mkows / load-resource.scala
Created November 5, 2018 16:57 — forked from banjeremy/load-resource.scala
scala: load files from resources directory
def loadResource(filename: String) = {
val source = scala.io.Source.fromURL(getClass.getResource(filename))
try source.mkString finally source.close()
}
@mkows
mkows / gist:d6a6726b1cbea64574746366290506ce
Created November 13, 2018 17:21
pretty json in command line
echo '{"yo":"boo", "so":"no"}' | python -m json.tool
{
"so": "no",
"yo": "boo"
}