Skip to content

Instantly share code, notes, and snippets.

@mkows
mkows / init-scala.sh
Last active August 29, 2015 14:15 — forked from maciej/init-scala.sh
#!/bin/bash
PROJECT_NAME="$1"
SCALA_VERSION="2.9.1"
SCALATEST_VERSION="1.6.1"
MOCKITO_VERSION="1.8.5"
mkdir $PROJECT_NAME
cd $PROJECT_NAME
@mkows
mkows / scala-test.template
Last active August 29, 2015 14:15
Scala Test - IntelliJ Template
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.mockito.Mockito._
import org.mockito.Matchers._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.mock.MockitoSugar
import org.scalatest.{Matchers, FunSpec}
class ${NAME} extends FunSpec with Matchers with MockitoSugar with ScalaFutures {
@mkows
mkows / scala-spec.template
Last active August 29, 2015 14:15
Scala Spec - IntelliJ Template
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.mockito.Mockito._
import org.mockito.Matchers._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.mock.MockitoSugar
import org.scalatest.{Matchers, WordSpecLike}
class ${NAME} extends WordSpecLike with Matchers with MockitoSugar with ScalaFutures {
@mkows
mkows / gist:ad0b06738ff6b933f8b0
Last active August 29, 2015 14:21
scala-spec-min.template
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{Matchers, WordSpecLike}
class ${NAME} extends WordSpecLike with Matchers with ScalaFutures {
"${NAME}" should {
"" in {
@mkows
mkows / iterm.scpt
Last active June 2, 2016 10:47 — forked from gnachman/iterm.scpt
Fix docker quickstart terminal for iTerm2 version 3.0
-- /Applications/Docker/Docker\ Quickstart\ Terminal.app/Contents/Resources/Scripts/iterm.scpt
set itermRunning to (application "iTerm" is running)
set scriptPath to quoted form of POSIX path of ((path to me as text) & "::" & "start.sh")
set user_shell to do shell script "dscl /Search -read /Users/$USER UserShell | awk '{print $2}'"
tell application "iTerm"
activate
if not (exists window 1) or (itermRunning = false) then
reopen
end if
@mkows
mkows / fs2-process-seq.scala
Last active August 4, 2016 16:25
fs2 big-bang vs sequential processing of Seq
object Fs2GuideApp extends App {
import fs2.Stream
import fs2.Task
def printTask(i: Int): Task[Boolean] = {
Task.delay {
println(s"started: $i")
Thread.sleep(200)
println(s"ended__: $i")
@mkows
mkows / push-entries.py
Created September 19, 2016 14:56
Send entries as JSON to API via POST
# Send file entries (each per line) via POST.
#
# Assumes that:
# - api consumes entries asynchronously,
# - it takes api 1s to process each entry (hence waits 25+5s after each page of 25)
#
# Replacement for:
#
# curl \
# -X POST \
#
# This script creates a file with entries from 'file_all_entries_path' file that are
# not blacklisted by entries in 'blacklisted_entries_path' file.
#
# Usage:
# python remove-blacklisted.py
import datetime
import time
import datetime
import time
# Find out lines occurring in both "file_a" and "file_b" and print to "output-<ts>.txt"
def build_timestamp():
t = time.time()
return datetime.datetime.fromtimestamp(t).strftime('%Y%m%d-%H%M%S')
# params
@mkows
mkows / intellij-scala-flat-spec-less.vm
Last active February 24, 2017 11:50
IntelliJ Scala Flat Spec Template (Matchers only)
#if ((${PACKAGE_NAME} && ${PACKAGE_NAME} != ""))package ${PACKAGE_NAME} #end
import org.scalatest.{FlatSpec, Matchers}
#set($NAME_WITHOUT_SUFFIX4 = $NAME.length() - 4)
class ${NAME} extends FlatSpec with Matchers {
"${NAME.substring(0, $NAME_WITHOUT_SUFFIX4)}" should "_" in {
}