Skip to content

Instantly share code, notes, and snippets.

@mmynsted
mmynsted / gist:921b32d06763cb7d9a34
Created May 8, 2015 21:51
sqlite3 recovery attempt for macports
# pushd /opt/local/var/macports/registry
# mv registry.db registry.db.old
# sqlite3 registry.db.old
sqlite> .load /opt/local/var/macports/sources/rsync.macports.org/release/base/src/cregistry/macports.sqlext
sqlite> .mode insert
sqlite> .output dump_all.sql
sqlite> .dump
sqlite> .exit
@mmynsted
mmynsted / gist:4dab481b6144d997057c
Created December 17, 2014 02:58
Outstanding FP, CS, and other books we like.
#!/bin/bash
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

...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

@mmynsted
mmynsted / stopwatch
Created April 9, 2014 17:57
A simple stopwatch
!/bin/sh
count=0
interval=60
while true
do
echo -ne "$(date +%Y-%m-%dT%H:%M:%S) | $((count/interval)) mins : $1"'\r'
let count+=interval
sleep $interval
done
@mmynsted
mmynsted / gist:10166486
Created April 8, 2014 18:20
scalacflags
val scalacFlags = Seq(
"-deprecation",
"-encoding", "UTF-8",
"-feature",
"-language:existentials",
"-language:experimental.macros",
"-language:higherKinds",
"-language:implicitConversions",
"-unchecked",
"-Xfatal-warnings",
@mmynsted
mmynsted / SeqStringToOptionString
Created March 27, 2014 00:37
The question was about creating an Option[String] from a Seq[String]
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
mmynsted / gist:7046872
Last active December 25, 2015 21:59
Functional Programming Glossary - please update/correct as needed

Glossary of Functional Programming Terms

Functor

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]