Skip to content

Instantly share code, notes, and snippets.

View jrmsamson's full-sized avatar
😄

Jerome Samson jrmsamson

😄
View GitHub Profile
@jrmsamson
jrmsamson / SimpleHandlerSpec.scala
Created February 25, 2022 14:57
How to test zio-lambda
package zio.lambda.example
import zio.Console._
import zio.Random
import zio._
import zio.json._
import zio.lambda._
import zio.test._
final case class CustomEvent(message: String)

Fibers

Fibers are an abstraction over sequential computation, similar to threads but at a higher level. There are two ways to think about this model: by example, and abstractly from first principles. We'll start with the example.

(credit here is very much due to Fabio Labella, who's incredible Scala World talk describes these ideas far better than I can)

Callback Sequentialization

Consider the following three functions

@jrmsamson
jrmsamson / create_monorepo.sh
Last active January 25, 2019 15:43
Merge multiple repos into a monorepo
# Reference: http://honnef.co/posts/2016/04/merging-git-repositories/
#!/bin/bash
base=baseUrl
projects=(project1 project2)
new_repo=agua
mkdir -p "$new_repo"
cd "$new_repo"
# FROM instructions support variables that are declared by any ARG instructions
# Docker has a set of predefined ARG variables that you can use without a
# HTTP_PROXY, HTTPS_PROXY, FTP_PROXY, NO_PROXY
ARG CODE_VERSION=latest
# Initializes a new build stage and sets the Base Image for subsequent instructions
FROM ImageName:${CODE_VERSION}
# RUN has 2 forms:
# - RUN <command> (shell form)
@jrmsamson
jrmsamson / docker_swarm.txt
Last active August 30, 2018 13:59
Common docker swarm commands
docker swarm init
docker swarm join-token manager
docker node ls
docker node ps node1
docker service (replace the run command)
@jrmsamson
jrmsamson / docker-clear.bat
Last active July 2, 2018 22:28
Delete all docker images from your windows host
@echo off
FOR /f "tokens=*" %%i IN ('docker ps -aq') DO docker rm %%i
FOR /f "tokens=*" %%i IN ('docker images --format "{{.ID}}"') DO docker rmi %%i