Skip to content

Instantly share code, notes, and snippets.

View markus1189's full-sized avatar

Markus Hauck markus1189

  • Frankfurt am Main, Germany
View GitHub Profile
@markus1189
markus1189 / transaction.scala
Last active April 5, 2021 08:43
Using given for a function argument in Scala 3
// Example from https://www.scala-lang.org/blog/2016/12/07/implicit-function-types.html
import scala.collection.mutable.ListBuffer
import scala.util.chaining.*
class Transaction:
private val log = ListBuffer[String]()
private var aborted = false
private var committed = false
def println(s: String): Unit =
@markus1189
markus1189 / dungeondraft.nix
Created March 27, 2021 14:20
Nix buildFHSEnv for DungeonDraft
{ pkgs ? import <nixpkgs> { } }:
(pkgs.buildFHSUserEnv {
name = "DungeonDraftFhs";
targetPkgs = pkgs:
with pkgs; [
alsaLib
libglvnd
pulseaudioLight
] ++ (with xlibs; [
@markus1189
markus1189 / owm.nix
Created March 27, 2021 13:56
Nix buildFHSEnv expression for OtherWorldMapper (Demo)
{ pkgs ? import <nixpkgs> {}}:
(pkgs.buildFHSUserEnv {
name = "OtherWorldMapper-FHS";
targetPkgs = pkgs: with pkgs; [
gtk2-x11
xorg.libX11
expat
util-linux
pango
@markus1189
markus1189 / ZipArchiveStream.scala
Created July 3, 2019 08:10
Streaming creation of a zip archive with akka-streams
import java.io.ByteArrayOutputStream
import java.nio.charset.StandardCharsets
import java.nio.file.{Path, Paths}
import java.util.zip.{ZipEntry, ZipOutputStream}
import akka.NotUsed
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, IOResult}
import akka.stream.scaladsl.{FileIO, Flow, Keep, Source}
import akka.util.ByteString
@markus1189
markus1189 / docker.nix
Last active January 4, 2019 15:12
DockerTools Problem
{ pkgs ? import <nixpkgs> {} }: with pkgs.dockerTools;
let
someBaseImage = pullImage {
imageName = "nixos/nix";
imageDigest = "sha256:1b97dc98b599779d80271d4203275627c0749d8bd5e9b9c868154249395cbc1b";
sha256 = "134h20xgpqchcvgv0f13knsi2p7jfl4m9mk8hkvdgh8hnz0hj3hc";
};
in
buildImage {
@markus1189
markus1189 / docker.nix
Created January 4, 2019 15:07
DockerTools Problem
{ pkgs ? import <nixpkgs> {} }: with pkgs.dockerTools;
let
someBaseImage = pullImage {
imageName = "nixos/nix";
imageDigest = "sha256:1b97dc98b599779d80271d4203275627c0749d8bd5e9b9c868154249395cbc1b";
sha256 = "134h20xgpqchcvgv0f13knsi2p7jfl4m9mk8hkvdgh8hnz0hj3hc";
};
in
buildImage {
@markus1189
markus1189 / dyalog.nix
Last active December 19, 2018 17:52
WIP of packaging Dyalog APL using nix
{ pkgs ? import <nixpkgs> {}}: with pkgs;
let
libPath = stdenv.lib.makeLibraryPath (with pkgs.xorg; [
alsaLib
atk
cairo
cups
dbus_daemon.lib
expat
@markus1189
markus1189 / shell.nix
Created July 15, 2018 08:33
nix shell environment for the "category for programmers" latex build
# Run this command to build the pdf:
# > nix-shell --pure shell.nix --command 'cd src; make'
{ pkgs ? import <nixpkgs> {} }: with pkgs;
mkShell {
FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ inconsolata-lgc libertine libertinus ]; };
buildInputs = [
(texlive.combine {
inherit (texlive)
fvextra
// -*- compile-command: "scalafmt Code.scala && amm Code.scala" -*-
/*
Code for the Java-Magazin Article
Author: Markus Hauck, codecentric AG
You can execute this using ammonite (http://ammonite.io/#Ammonite-REPL)
> amm Code.scala
Alternatively, you can take all $ivy imports and build an sbt project yourself
*/
@markus1189
markus1189 / desktopdungeons.nix
Last active February 6, 2018 06:28
DesktopDungeons on Nix(OS)
# Nix build file for Desktop Dungeons
# nix-build --argstr savesDir ~/DDSaves DesktopDungeons.nix
{ pkgs ? import <nixpkgs> { system = "i686-linux";}
, savesDir
}: with pkgs;
assert lib.pathExists savesDir;
stdenv.mkDerivation rec {
name = "desktop-dungeons";