Skip to content

Instantly share code, notes, and snippets.


Mateusz Kubuszok MateuszKubuszok

View GitHub Profile
MateuszKubuszok /
Last active Oct 14, 2021
Useful Ammonite snippets

Useful Ammonite snippets

All of these can be figured out by looking at and at libraries pages, but to make things faster for myself I written it down (I don't always want to search through Ammonite history nor pollute my ~/.ammonite/

For convenience, next to library there is badge with the newest version and next to one liners for Ammonite for specific version is link to releases - it let you update to newest version without goolging or checking project's site.

MateuszKubuszok / Uncurry.scala
Created Mar 14, 2020
Sometimes I missed .uncurried cuntionality in Scala
View Uncurry.scala
trait Uncurry[C, U] {
def uncurried(curried: C): U
object Uncurry {
def instance[C, U](body: C => U) = new Uncurry[C, U] {
def uncurried(curried: C): U = body(curried)
implicit def uncurry2[A, B, Out]: Uncurry[A => B => Out, (A, B) => Out] =
instance[A => B => Out, (A, B) => Out] { curried => curried(_)(_) }
implicit def uncurry3[A, B, C, Out]: Uncurry[A => B => C => Out, (A, B, C) => Out] =
MateuszKubuszok / .tmux.conf
Created Jan 4, 2020
Sane Tmux config which can be used with mouse and have nice copy/tiling/searching things turned on and added to right mouse button menu
View .tmux.conf
# Open window/pane in the same PATH
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
# Reload config
bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
# Window tab menu
bind-key -T root MouseDown3Status display-menu -T "#[align=centre]#{window_index}:#{window_name}" -t = -x W -y S \
"Swap Left" l "swap-window -t:-1" \
MateuszKubuszok / parser_combinators.scala
Created Mar 18, 2019
Simple parser combinators example
View parser_combinators.scala
// Parser definitions
type Parser[+A] = String => Option[(A, String)]
object Parser{
def apply[A](re: String)(f: String => A): Parser[A] =
input => s"""\\s*($re)(\\s*)""".r
.map { n =>
View ReverseState.scala
// based on
import $ivy.`org.typelevel::cats-core:1.4.0`, cats._, cats.implicits._
//import $plugin.$ivy.`org.spire-math::kind-projector:0.9.4`
//import $plugin.$ivy.`com.olegpy::better-monadic-for:0.2.4`
class ReverseState[S, A](val runF: Eval[Eval[S] => (Eval[S], Eval[A])]) {
MateuszKubuszok / Dockerfile
Created Sep 26, 2018
Docker without root owning all files created outside
View Dockerfile
FROM anapsix/alpine-java:8_jdk
RUN apk add su-exec
COPY /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/"]
WORKDIR /build
MateuszKubuszok /
Created Jul 26, 2018
Publishing and testing Jekyll sites
#!/bin/bash --login
ThisDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$ThisDir/.."
if [ ! `command -v jekyll > /dev/null` ]; then
rvm use default ruby
bundle install
MateuszKubuszok /
Last active May 8, 2019
Showoff code that I probably wouldn't use on production, but looks smarter than whatever stuff is actually required in our everyday coding :P
// @author: Mateusz Kubuszok
// requirements: ammonite 1.1.0
// usage: run `amm` and copy paste into REPL
import $ivy.`org.typelevel::cats-core:1.3.1`, cats._, cats.syntax.all._
import $ivy.`org.typelevel::cats-effect:1.0.0`, cats.effect._, cats.effect.syntax._
import $ivy.`io.circe::circe-core:0.9.3`, io.circe._, io.circe.syntax._
import $ivy.`io.circe::circe-generic:0.9.3`,
View OptMapOps.scala
implicit final class OptMapOps[A](self: A) {
def optMap[B, C >: A](otherOpt: Option[B])(f: (A, B) => C): C = otherOpt match {
case Some(other) => f(self, other)
case None => self
// sequence.mapOps(optionalFilter) { case (seq, filter) => filter(seq) }.otherOps(args)
apply1() (
block() {
eval "$body"
block "$1"