Skip to content

Instantly share code, notes, and snippets.

Jeff Foster fffej

Block or report user

Report or block fffej

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 DynamicTimeWarping.hs
dtw :: V.Vector a -> V.Vector a -> (a -> a -> Int) -> Array (Int,Int) Int
dtw x y cost = runSTArray $ do
let n = V.length x
m = V.length y
maxcost = maxBound
d <- newArray ((0,0),(m,n)) 0
forM_ [1..n] (\i -> writeArray d (0,i) maxcost)
forM_ [1..m] (\i -> writeArray d (i,0) maxcost)
forM_ [1..n] $ \i ->
forM_ [1..m] $ \j -> do
@fffej
fffej / StableMarriageProblem.hs
Created Jul 14, 2014
Stable Marriage Problem
View StableMarriageProblem.hs
import Data.List
import Data.Maybe
stableMatch :: (Eq m, Eq w) => [(m,[w])] -> [(w,[m])] -> [(m,w)]
stableMatch ms ws = stableMatch' []
where
stableMatch' ps = case unmarried ms ps of
Just unmarriedMan -> stableMatch' (findMatch unmarriedMan ws ps)
Nothing -> ps
View gist:6053800
@mixin border {
border: 1px solid #333;
}
article.post {
background: #eee;
@include border;
}
ul.menu {
background: #ccc;
@include border;
View gist:5419140
private LiveDatabase RefreshLiveDatabase(LiveDatabase source, int whichDatabase)
{
source.Cleanup();
var original = whichDatabase == 1 ? m_DB1Original : m_DB2Original;
return original.ToLive();
}
@fffej
fffej / gist:4135446
Created Nov 23, 2012
WWII Pigeon Message
View gist:4135446
AOAKN HVPKD FNFJW YIDDC
RQXSR DJHFP GOVFN MIAPX
PABUZ WYYNP CMPNW HJRZH
NLXKG MEMKK ONOIB AKEEQ
WAOTA RBQRH DJOFM TPZEH
LKXGH RGGHT JRZCQ FNKTQ
KLDTS FQIRW AOAKN 27 1525/6
@fffej
fffej / FactorsAndMultiples.hs
Created Oct 17, 2012
Best first search for factors and multiples
View FactorsAndMultiples.hs
module FactorsAndMultiples where
import Data.List
import Data.Ord (comparing)
isFom :: Int -> Int -> Bool
isFom x y = x `mod` y == 0 || y `mod` x == 0
isSequenceValid :: [Int] -> Bool
isSequenceValid [] = True
View expressions.java
public interface Expression {
int evaluate();
}
public class Constant implements Expression {
private final int value;
Constant(int value) { this.value = value; }
public int evaluate() { return value; }
View terribleTest.java
@Test
public void test() {
Environment env = new Environment();
env.register(assign($("a"), plus($("b"), $("c"))));
env.register(assign($("c"), multiply($(2), $("d"))));
env.register(assign($("b"), $(3)));
env.register(assign($("d"), $(2)));
Assert.assertThat(env.valueOf($("a")), equalTo(7));
@fffej
fffej / SensibleNotCensorShip.html
Created Jun 29, 2012
Sensible Not CensorShip
View SensibleNotCensorShip.html
The responsibility for controlling a child's access to the Internet should lie with the parents, not with a central Government authority.
@fffej
fffej / fp.dot
Created May 2, 2012 — forked from fogus/fp.dot
early influence graph of fp languages
View fp.dot
digraph G {
KRC -> Miranda;
ML -> Miranda;
KRC -> SASL;
SASL -> Miranda;
Miranda -> Haskell;
Hope -> Haskell;
ML -> Caml;
Caml -> FSharp;
Clean -> Haskell;
You can’t perform that action at this time.