Skip to content

Instantly share code, notes, and snippets.

private static Map<String, Sequence<String>> zipmap (Sequence<String> keys, Sequence<Sequence<String>> vals) {
return keys.zip(vals).fold(Maps.<String, Sequence<String>>map(), (Callable2<? super Map<String, Sequence<String>>, ? super Pair<String, Sequence<String>>, ? extends Map<String, Sequence<String>>>) Maps.asMap());
}
private static Map<String, Sequence<String>> zipmapversion2 (Sequence<String> keys, Sequence<Sequence<String>> vals) {
Sequence<Pair<String,Sequence<String>>> keysAndVals = keys.zip(vals);
Map<String, Sequence<String>> map = Maps.map();
return keysAndVals.fold(map,wtf());
}
(ns fbcorelogic.core
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn validkeyo [key]
(conde
[(emptyo key)]
[(fresh [first-of-key rest-of-key]
(resto key rest-of-key)
(validkeyo rest-of-key)
@jennifersmith
jennifersmith / problem140
Created December 17, 2012 21:22
problem 140
(fn [sos]
(letfn [
(combine [x y]
(let [diff [nil (.toUpperCase (str (clojure.set/difference x y)))] ]
(conj (clojure.set/intersection x y) diff)))
(remove-dontcares [minterms] (set (remove vector? minterms)))
(get-off-by-ones [all-minterms [current-key current-vals]]
(let [
off-by-one
(map #(combine current-key %)
(defn which-am-i [unranked-value]
(let [all-the-things
(map #(vector (first %1) (distance-between (second %1) unranked-value)) all-the-averages)
top-two (take 2 (sort-by second all-the-things))
difference-between-top-two (Math/abs (apply - (map second top-two)))
very-close (< difference-between-top-two 50)
best-one (if
very-close
(ffirst (shuffle top-two))
@jennifersmith
jennifersmith / team5mark2.clj
Created August 1, 2012 12:33
Team 5 second attempt
(ns maze.team5mark2)
(def next-directions
{
:n [:w :n :e :s]
:w [:s :w :n :e]
:s [:e :s :w :n]
:e [:n :e :s :w]
}
)
(defn not-dead-end [direction [leng & side-passages]]
@jennifersmith
jennifersmith / team5.clj
Created August 1, 2012 12:33
Team 5 first attempt
(ns maze.team5)
(def next-directions
{
:n [:w :n :e :s]
:w [:s :w :n :e]
:s [:e :s :w :n]
:e [:n :e :s :w]
}
)
@jennifersmith
jennifersmith / gist:2962703
Created June 20, 2012 22:49
release_dates.sh
all_release_branch_names=($(git show-ref | grep 'release_' | cut -d' ' -f 2))
for branch in $all_release_branch_names; do
commit_where_it_branched_from_master= $(git merge-base ${branch} master)
git show $commit_where_it_branched_from_master -s --pretty=format:"$commit_it_where_branched_from_master branched from master on %cd"
done
1) Download cloc, chmod it and have it on your path somewhere (as cloc)
2) get the scan-history script
curl https://raw.github.com/rhunter/git-scan-history/master/bin/git-scan-history > ~/bin/git-scan-history
3) chmod it
chmod +x ~/bin/git-scan-history
1169071810 0
1169138071 6294
1169143071 23245
1169143580 23245
1169144084 23275
1169145926 23275
1169149435 31231
1169150235 34922
1169153198 47651
1169153433 30684
@jennifersmith
jennifersmith / hacky_data_stuff.clj
Created June 18, 2012 20:48
hacky_data_stuff.clj
(ns git-charts.core
(:use [incanter.core] [incanter.zoo])
(:require (incanter stats charts io)))
(defn read-dataset []
(incanter.io/read-dataset "/Users/jen/Dropbox/legacy codebase/ove-gitstats/lines_of_code.dat" :delim \space))
(defn clean-dataset [ds]
(incanter.core/col-names ds [:Date :Locs]))