Skip to content

Instantly share code, notes, and snippets.

View mads-hartmann's full-sized avatar

Mads Hartmann mads-hartmann

View GitHub Profile

Table of contents

@mads-hartmann
mads-hartmann / anything-dirty.sh
Created March 20, 2018 19:58
🤖 Tiny script to check if I had any dirty repos or un-pushed branches before sending my MBP to repair.
#!/bin/bash
set -euo pipefail
function is-git-repository {
[[ -d "$1/.git" ]] || (cd "$1" && git rev-parse --git-dir > /dev/null 2>&1)
}
function echo-is-dirty {
cd "$1"
if [[ ! -z $(git status -s) ]]
@mads-hartmann
mads-hartmann / GADT.scala
Created January 23, 2018 15:50
GADT Example Translation from OCaml to Scala
// I tried to translate the GADT examples I have in my blog post[1] about GADTs
// from OCaml to Scala.
//
// A direct translation resulted in the code below, but I had to add two asInstanceOf
// so I don't consider this a successful translations.
//
// Any idea how to get rid of the asInstanceOf calls? Is it even possible?
//
// [1]: http://mads-hartmann.com/ocaml/2015/01/05/gadt-ocaml.html
@mads-hartmann
mads-hartmann / prototype-deploy.sh
Created August 20, 2017 10:10
A small script for deploying a Docker service to a docker-machine. Suitable to prototypes and small hobby projects.
#!/bin/bash
#
# usage: prototype-deploy <machine-name> <image-name> <container-name>
#
set -euo pipefail
#
# Functions
#
@mads-hartmann
mads-hartmann / mhj-explore-toggle-mod.el
Created March 17, 2017 09:11
A modification to mhj/show-project-explorer as requested by Benjamín Buccianti
(defun mhj/show-project-explorer ()
"Project dired buffer on the side of the frame.
Shows the projectile root folder using dired on the left side of
the frame and makes it a dedicated window for that buffer."
(let ((buffer (dired-noselect (projectile-project-root))))
(progn
(display-buffer-in-side-window buffer '((side . left) (window-width . 0.2)))
(set-window-dedicated-p (get-buffer-window buffer) t)
(select-window (get-buffer-window buffer)))))
@mads-hartmann
mads-hartmann / keybase.md
Created August 31, 2016 07:57
My publicly-auditable identity

Keybase proof

I hereby claim:

  • I am mads-hartmann on github.
  • I am mads_hartmann (https://keybase.io/mads_hartmann) on keybase.
  • I have a public key whose fingerprint is BF71 A0F9 6C4C B0DF F30D 73D5 99E6 8045 0B61 2B11

To claim this, I am signing this object:

@mads-hartmann
mads-hartmann / init.js
Created November 23, 2015 13:54
Just-one-space (from Emacs) implementation for Atom
"use babel";
atom.commands.add('atom-text-editor', 'hartmann:just-one-space', () => {
const editor = atom.workspace.getActiveTextEditor();
if (!editor) {
return;
}
const changes = editor.getCursorBufferPositions().map((point) => {
@mads-hartmann
mads-hartmann / keybase.md
Created July 16, 2015 16:53
Verifying my Github account on keybase

Keybase proof

I hereby claim:

  • I am mads379 on github.
  • I am mads_hartmann (https://keybase.io/mads_hartmann) on keybase.
  • I have a public key whose fingerprint is BF71 A0F9 6C4C B0DF F30D 73D5 99E6 8045 0B61 2B11

To claim this, I am signing this object:

(add-hook 'eshell-mode-hook
(lambda ()
(define-key eshell-mode-map (kbd "C-c") 'eshell-kill-process)))
object Peano {
sealed trait Nat
trait Zero extends Nat
object ZeroV extends Zero
case class Succ[A <: Nat](x: A) extends Nat
trait Sum[A <: Nat, B <: Nat] {
type Out <: Nat
}