Skip to content

Instantly share code, notes, and snippets.

View augi's full-sized avatar

Michal Augustýn augi

View GitHub Profile
@augi
augi / SlickToDoobieNotes.md
Last active September 1, 2019 08:24
Slick to doobie notes
  • doobie uses ConnectionIO instead of DBIO in Slick. Both are composable using for-comprehension.
  • In Slick, you write connection.run(someDBIO) while in doobie someConnectionIO.transact(connection)
    • Slick: conn.run(sqlu"INSERT INTO FileData (fileId, data) VALUES (${s.fileId}, ${s.data})"
    • doobie: sql"INSERT INTO FileData (fileId, data) VALUES (${s.fileId}, ${s.data})".update.run.transact(conn)
  • In Slick, you have to explicitly say that the statements will run in the same transaction. In doobie, the transact method always runs all the statements in one transaction.
  • To distinguish between queries and non-queries, you use sql and sqlu interpolators in Slick. In doobie, you always use sql interpolator but the suffix differs:
    • Query: sql"SELECT data FROM FileData WHERE fileId = ${fileId}".query[FileData].to[Seq].transact(conn)
    • Streaming query: sql"SELECT data FROM FileData WHERE fileId = ${fileId}".query[FileData].stream.transact(conn)
    • Non-query: `sql"INSERT INTO File
@augi
augi / Dockerfile
Created June 29, 2018 13:24
Android build Dockerfile
FROM openjdk:8u111-jdk
ARG ANDROID_SDK_VERSION=24.4.1
ARG ANDROID_BUILD_TOOLS_VERSION=23.0.3
ARG ANDROID_API_LEVELS=android-23
ENV ANDROID_SDK_FILENAME android-sdk_r${ANDROID_SDK_VERSION}-linux.tgz
ENV ANDROID_SDK_URL http://dl.google.com/android/${ANDROID_SDK_FILENAME}
ENV ANDROID_HOME /opt/android-sdk-linux
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/build-tools/${ANDROID_BUILD_TOOLS_VERSION}
@augi
augi / setup_docker.cmd
Last active January 15, 2016 20:57
Script to be executed after Windows starts, requires Docker Toolbox installed.
@ECHO OFF
SET VM_NAME=default
SET MOUNT_SRC=E:\Work
SET MOUNT_DST=/e/work
SET MOUNT_NAME=work
ECHO Creating VirtualBox machine '%VM_NAME%'...
docker-machine create --driver virtualbox --virtualbox-host-dns-resolver %VM_NAME%