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 / zoom.nix
Last active January 17, 2018 19:44
Nix build for the zoom client from zoom.us
{ pkgs ? import <nixpkgs> {} }: with pkgs;
stdenv.mkDerivation rec {
name = "zoom-${version}";
version = "2.0.115900.1201";
src = fetchurl {
url = "https://zoom.us/client/${version}/zoom_x86_64.tar.xz";
sha256 = "1ssd1mdmbxdf5b2drv23ag8hznlj29b1qaldsn3gpn94mzvh6nrl";
};
@markus1189
markus1189 / keybase.md
Last active January 14, 2018 09:04
keybase.md

Keybase proof

I hereby claim:

  • I am markus1189 on github.
  • I am markus1189 (https://keybase.io/markus1189) on keybase.
  • I have a public key ASBPUi8X0YfGs5fiDuxchE5N7am75W2C1qrb0U6lu-mUFgo

To claim this, I am signing this object:

@markus1189
markus1189 / scalafmt-nixexpr.hs
Last active December 8, 2017 08:37
Scalafmt nixpkgs generator
#! /usr/bin/env nix-shell
#! nix-shell -i 'runhaskell --ghc-arg=-threaded'
#! nix-shell -p 'ghc.withPackages (p: with p; [ turtle text hnix ])'
#! nix-shell -p coursier nix
#! nix-shell --pure
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
import qualified Control.Foldl as Foldl
trait Monoid[A] {
def zero: A
def op(lhs: A, rhs: A): A
}
def listMonoid[A]: Monoid[List[A]] = new Monoid[List[A]] {
override def zero: List[A] = List()
override def op(lhs: List[A], rhs: List[A]): List[A] =
@markus1189
markus1189 / csvencoder.scala
Created March 24, 2017 11:09
Generic csv encoder with shapeless
// for ammonite
// import $ivy.`com.chuusai::shapeless:2.3.2`
import shapeless._
import shapeless.labelled._
import shapeless.ops.hlist._
import shapeless.ops.record._
case class IceCream(flavour: String, price: Int)
@markus1189
markus1189 / default.nix
Last active December 11, 2023 13:54
HumbleBundle DoorKickers NixOS
# Nix file for DoorKickers
#
# - make sure 'DoorKickers.tar.gz' is in the same dir
# - run:
# $ nix-build -E 'with import <nixpkgs> { }; callPackage_i686 ./default.nix { }'
{lib, openal, glibc, libGL, libX11, libogg, xorg, makeWrapper, stdenv }:
stdenv.mkDerivation {
name = "DoorKickers";
src = ./DoorKickers.tar.gz;
@markus1189
markus1189 / writePureScriptBin.nix
Last active August 28, 2016 18:55
Manage scripts with Nix
{ pkgs ? import <nixpkgs> {}}:
with pkgs;
let
writePureScriptBin = { name, deps ? [], interp ? stdenv.shell }: text:
writeScriptBin name ''
#!${interp}
export PATH=${lib.makeBinPath deps}
@markus1189
markus1189 / HouseBuilder.scala
Last active January 31, 2016 10:01
Building houses in a type safe way
// source: https://gist.github.com/markus1189/760d1078b462c282ab44
/* Example of using phantom types to make a type safe builder.
* A House requires:
* - a roof which can be either flat or normal
* - a base, after one set this can never be removed again and neither added again
* - side walls, can be removed/added if (not) present
* - a door, can be removed/added if (not) present
*
* the `build` method can only be called if the builder is in a valid
* state and will create the correct result type, e.g. a flat house or
@markus1189
markus1189 / switch.hs
Created January 30, 2016 14:36
Haskell LightSwitch
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
module LightSwitch where
data Power = On | Off
type family Toggle (a :: Power) where
Toggle On = Off
Toggle Off = On
@markus1189
markus1189 / lightswitch.scala
Last active January 31, 2016 08:30
Safe LightSwitch using phantom types and typelevel calculation
sealed abstract class Power
final abstract class On extends Power
final abstract class Off extends Power
class LightSwitch[State <: Power] private {
def on(implicit ev: State =:= Off) = LightSwitch.on
def off(implicit ev: State =:= On) = LightSwitch.off
def toggleP[S<:Power](implicit t: ToggleP[State,S]): LightSwitch[S] = new LightSwitch[S]
def toggleM[S<:Power](implicit t: ToggleM.Aux[State,S]): LightSwitch[S] =
new LightSwitch[S]