Skip to content

Instantly share code, notes, and snippets.

View mkhl's full-sized avatar
🖤
…at any cost

Martin Kühl mkhl

🖤
…at any cost
View GitHub Profile
@mkhl
mkhl / README.md
Created November 2, 2017 10:16
Tail-recursive Tree fold using CPS

Tail-recursive Tree fold

Both the original and the proposed solution assume an associative and commutative combining function (g).

That bugged me so a colleague and I put this together.

Keybase proof

I hereby claim:

  • I am mkhl on github.
  • I am mkhl (https://keybase.io/mkhl) on keybase.
  • I have a public key ASDOZDDY2WKJiu0GMeVXecOv_KalOkFnJhahWX-vYhWcAAo

To claim this, I am signing this object:

# Demonstration for https://github.com/atom/text-document/issues/15
# Expand this snippet, type "foo" for the first placeholder, hit <Tab>
'.text.plain':
'Test: Adjacent Tabstops':
'prefix': 'a'
'body': '${1:abc}${2:def}'
From d3180baace023233e9fff2d049bcd7beb143f853 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20K=C3=BChl?= <martin.kuehl@innoq.com>
Date: Thu, 31 Mar 2016 19:20:00 +0200
Subject: [PATCH] Test operation with path inside `$TMPDIR`
---
js/spec/index-spec.js | 3 ++-
package.json | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
@mkhl
mkhl / t
Created March 16, 2016 21:19
“switch” files interactively
#!/bin/bash
function list {
if git rev-parse &>/dev/null; then
git ls-files
else
find . -type f | cut -c 3-
fi
}
@mkhl
mkhl / ...sh
Created February 24, 2016 19:37
.. # "cd up" by ${1:-1} directories
cd $(seq -f .. -s / 1 ${1:-1})
cd $(jot -b .. -s / ${1:-1})
# using jot(1) is shorter, and doesn't add a trailing /
# but as far as I recall, jot(1) isn't part of GNU userland
#!/bin/sh
git add --update -- "$@"
git commit --message="trash -- $(date)" -- "$@"
git reset --soft HEAD^
git reset --quiet -- "$@"
git checkout -- "$@"
extension NSComparisonResult {
init() {
self = .OrderedSame
}
var isAscending: Bool {
return self == .OrderedAscending
}
var isDescending: Bool {
#!/usr/bin/env ruby -w
require "rubygems"
require "nokogiri"
require "open-uri"
PROGRAM_BASE = File.basename $PROGRAM_NAME
def usage
puts <<-USAGE
@mkhl
mkhl / power.swift
Created December 17, 2015 16:27
Power“sets” of Sequences in Swift
func power<Sequence: SequenceType>(items: Sequence) -> [[Sequence.Generator.Element]] {
return items.reduce([[]]) { (arrays, item) in
return arrays + arrays.map { (var array) in
array.append(item)
return array
}
}
}