#Mac OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package object mail { | |
implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
sealed abstract class MailType | |
case object Plain extends MailType | |
case object Rich extends MailType | |
case object MultiPart extends MailType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pretty straightforward, very similar to the Session object, except uses getters and setters | |
# to allow reactivity to happen 'magically' | |
class ReactiveObject | |
constructor: (attributes) -> | |
@attributes = attributes | |
@contexts = {} | |
_.each attributes, (v, key) => | |
@contexts[key] = {} | |
Object.defineProperty(this, key, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew update | |
brew versions FORMULA | |
cd `brew --prefix` | |
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions" | |
brew install FORMULA | |
brew switch FORMULA VERSION | |
git checkout -- Library/Formula/FORMULA.rb # reset formula | |
## Example: Using Subversion 1.6.17 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://en.wikipedia.org/wiki/Approximate_string_matching | |
function fuzzySearch(t, p) { // returns minimum edit distance between substring of t and p | |
var a = [], // current row | |
b = [], // previous row | |
pa = [], // from | |
pb = [], | |
s, i, j; | |
for (i = 0; i <= p.length; i++) { | |
s = b; | |
b = a; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.tixxit.levenshtein | |
import scala.math.min | |
object EditDistance { | |
def editDist[A](a: Iterable[A], b: Iterable[A]) = | |
((0 to b.size).toList /: a)((prev, x) => | |
(prev zip prev.tail zip b).scanLeft(prev.head + 1) { | |
case (h, ((d, v), y)) => min(min(h + 1, v + 1), d + (if (x == y) 0 else 1)) | |
}) last |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bisect | |
class NFA(object): | |
EPSILON = object() | |
ANY = object() | |
def __init__(self, start_state): | |
self.transitions = {} | |
self.final_states = set() | |
self._start_state = start_state |
NewerOlder