Skip to content

Instantly share code, notes, and snippets.

mmynsted / gist:7046872
Last active December 25, 2015 21:59
Functional Programming Glossary - please update/correct as needed
View gist:7046872

Glossary of Functional Programming Terms


A type constructor F[_] together with an operation forall A, B. (A => B) => F[A] => F[B] that satisfies FunctorLaw, i.e. that a series of maps may be freely rewritten as a single map on a composed function, and that the identity function, lifted, is a no-op.

A good example from scalaz

def map[A, B](fa: F[A])(f: (A) ⇒ B): F[B]

mmynsted / SeqStringToOptionString
Created March 27, 2014 00:37
The question was about creating an Option[String] from a Seq[String]
View SeqStringToOptionString
object Main extends App {
def toOpt(s: Set[String]): Option[String] = s match {
case x if !x.isEmpty => Some(x.mkString(" "))
case _ => None
val a: Set[String] = Set()
val b: Set[String] = Set("a", "b")
println(s"a = ${toOpt(a)}")
println(s"b = ${toOpt(b)}")
mmynsted / gist:10166486
Created April 8, 2014 18:20
View gist:10166486
val scalacFlags = Seq(
"-encoding", "UTF-8",
mmynsted / stopwatch
Created April 9, 2014 17:57
A simple stopwatch
View stopwatch
while true
echo -ne "$(date +%Y-%m-%dT%H:%M:%S) | $((count/interval)) mins : $1"'\r'
let count+=interval
sleep $interval
View gist:10397076

...perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away...

-- Antoine de Saint-Exupéry

rm -vrf /System/Library/Extensions/zfs.kext
rm -vrf /System/Library/Filesystems/zfs.fs
rm -vf /usr/lib/libzfs.dylib
rm -vrf /usr/lib/libzfs.dylib.dSYM
rm -vf /usr/lib/libzpool.dylib
rm -vrf /usr/lib/libzpool.dylib.dSYM
rm -vf /usr/local/bin/zoink
rm -vrf /usr/local/bin/zoink.dSYM
mmynsted / gist:4dab481b6144d997057c
Created December 17, 2014 02:58
Outstanding FP, CS, and other books we like.
mmynsted / gist:921b32d06763cb7d9a34
Created May 8, 2015 21:51
sqlite3 recovery attempt for macports
View gist:921b32d06763cb7d9a34
# pushd /opt/local/var/macports/registry
# mv registry.db registry.db.old
# sqlite3 registry.db.old
sqlite> .load /opt/local/var/macports/sources/
sqlite> .mode insert
sqlite> .output dump_all.sql
sqlite> .dump
sqlite> .exit
View gitconfig alias
co = checkout
br = branch
ci = commit
st = status -sb
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
ls = log --stat --oneline
ld = log --pretty=format:'%C(auto) %h [%C(green)%ar%C(reset)] %C(blue) %cn %C(reset)%C(auto) %d %<|(5) %s' --graph --decorate --all
f = "!git ls-files | grep -i"
dl = "!git ll -1"
View prepare-commit-msg
temp=`mktemp /tmp/git-XXXXX`
ticket=`git branch | grep '^\*' |sed -e 's@.*/@@'`
(printf "\n\n$ticket"; cat "$original") > "$temp"
cat "$temp" > "$original"