Skip to content

Instantly share code, notes, and snippets.

Michael Ummels ummels

Block or report user

Report or block ummels

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View maps.scala
val m = Map(0 -> 'a')
for (n <- 0 until 2) {
m.get(n) match {
case Some(x) => println(s"Value found for key $n: $x")
case None => println(s"No value found for key $n")
}
}
View pipetap.scala
/** Implicit class for adding `|>` and `tap` operations to `AnyVal`.
*
* See `http://stackoverflow.com/a/11120847/839131`.
*/
implicit class PipeAndTap[A](val x: A) extends AnyVal {
/** Applies `f` to the underlying value and returns the result. */
def |>[B](f: A => B) = f(x)
/** Applies `f` to the underlying value `x` (presumably with side effects)
* and returns `x`.
@ummels
ummels / Tram-BS.md
Last active Nov 9, 2015
Tram Braunschweig Werbeliste
View Tram-BS.md

Tram Braunschweig Werbeliste

Fahrzeugliste

GT6S (AEG/LHB)

9551 grau-weiß
9552 Fliesen Winter
9553 Schwarzer Herzog/Wolters Pilsener
9554 Mc V

View mergestream.scala
object Util {
/** Merges a collection of streams into a single stream.
*
* Returns a sorted stream if all input streams are sorted.
*/
def mergeStreams[A](streams: Traversable[Stream[A]])(implicit ord: Ordering[A]): Stream[A] = {
val streams1 = streams.toList filterNot (_.isEmpty) sortBy (_.head)
if (streams1.isEmpty)
Stream.empty
else {
@ummels
ummels / dijkstra.clj
Last active Aug 9, 2017
Dijsktra's shortest-path algorithm in Clojure
View dijkstra.clj
(require '[clojure.data.priority-map :refer [priority-map]])
(defn map-vals [m f]
(into {} (for [[k v] m] [k (f v)])))
(defn remove-keys [m pred]
(select-keys m (filter (complement pred) (keys m))))
(defn dijkstra
"Computes single-source shortest path distances in a directed graph.
@ummels
ummels / mydiss.cls
Last active Jan 30, 2020
Class file for my PhD thesis
View mydiss.cls
% Copyright (c) 2010 Michael Ummels <michael@ummels.de>
%
% Permission to use, copy, modify, and/or distribute this software for any
% purpose with or without fee is hereby granted, provided that the above
% copyright notice and this permission notice appear in all copies.
%
% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@ummels
ummels / fontforge.patch
Created Aug 21, 2012
Patch for compiling FontForge under OS X 10.7
View fontforge.patch
diff --git a/fontforge/macbinary.c b/fontforge/macbinary.c
index a452d5b..d90f567 100644
--- a/fontforge/macbinary.c
+++ b/fontforge/macbinary.c
@@ -37,7 +37,7 @@
#include "psfont.h"
#if __Mac
# include <ctype.h>
-# include </Developer/Headers/FlatCarbon/Files.h>
+# include <CoreServices/CoreServices.h>
@ummels
ummels / hack.sh
Created Mar 31, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
View ummels-4clojure-solution127.clj
;; ummels's solution to Love Triangle
;; https://4clojure.com/problem/127
(fn [mine]
(let [n (count mine)
ln #(loop [r 1 v %] (if (< v 2) r (recur (inc r) (quot v 2))))
m (apply max (map ln mine))
lmax (fn [xs] ; treats nil as -infinity
(let [a (first xs) r1 (rest xs) b (first r1) r2 (rest r1)]
(cond (empty? r1) a
You can’t perform that action at this time.