Skip to content

Instantly share code, notes, and snippets.

Scott Feeney graue

Block or report user

Report or block graue

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
@graue
graue / foo.js
Created Mar 4, 2014
Browserify source map test case
View foo.js
var _ = require('underscore');
function foo() {
_(['foo','bar','baz']).each(function(s) {
console.log(s);
});
}
module.exports = foo;
View val-map.clj
(defn val-map
"Map f over hashmap m's values. Should be in the dang core."
[f m]
(into {} (for [[k v] m] [k (f v)])))
View vectors.clj
(ns vectors
(:require [clojure.test :refer [deftest is run-tests]]))
(defprotocol VectorMath2D
(-vplus [v1 v2] "Adds two vectors"))
(defrecord Vec2D [x y]
VectorMath2D
(-vplus [v1 v2]
(Vec2D. (+ (:x v1)
@graue
graue / primes.clj
Created Jul 20, 2013
Lazy list of primes, as implemented in 15 minutes on the subway on my phone
View primes.clj
(defn divides [m n]
(= 0
(mod n m)))
(defn my-and [x y]
(and x y))
(defn all? [pred xs]
(reduce my-and true
(map pred xs)))
@graue
graue / gist:5945184
Created Jul 7, 2013
Clojure error message
View gist:5945184
Exception in thread "main" java.lang.IllegalArgumentException: Don't know how to create ISeq from: ring_intro.core$wrap_uri_check$fn__205, compiling:(core.clj:27:3)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3463)
at clojure.lang.Compiler$DefExpr.eval(Compiler.java:408)
at clojure.lang.Compiler.eval(Compiler.java:6624)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.loadResourceScript(RT.java:361)
at clojure.lang.RT.load(RT.java:440)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5028.invoke(core.clj:5530)
@graue
graue / userContent.css
Created May 27, 2013
My userContent.css for Firefox (makes Hacker News comments and Humbug messages more readable)
View userContent.css
@-moz-document url-prefix(https://news.ycombinator.com) {
.comment {
font-family: Alegreya, serif !important;
font-size: 15pt !important;
}
.comment code {
font-family: Inconsolata-g, fixed !important;
font-size: 10pt !important;
}
@graue
graue / soon.rs
Created May 26, 2013
Code using `map` that worked in Rust 0.5, but broke in 0.6
View soon.rs
fn main() {
let s = [1, 2, 3, 4].map(|&x| (x * x).to_str());
for s.each |&item| {
io::println(item);
}
}
@graue
graue / MergeSort.hs
Created May 10, 2013
Merge sort in Haskell
View MergeSort.hs
mergeSort :: Ord a => [a] -> [a]
mergeSort [] = []
mergeSort [x] = [x]
mergeSort xs = combineSortedLists
(mergeSort firstHalf)
(mergeSort secondHalf)
where (firstHalf, secondHalf) = splitInHalf xs
splitInHalf :: [a] -> ([a], [a])
splitInHalf xs = splitAt halfLength xs
@graue
graue / userContent.css
Created May 1, 2013
Firefox userContent.css to make Hacker News comments prettier
View userContent.css
@-moz-document url-prefix(https://news.ycombinator.com) {
.comment {
font-family: Alegreya, serif !important;
font-size: 15pt !important;
}
.comment code {
font-family: Inconsolata-g, fixed !important;
font-size: 10pt !important;
}
@graue
graue / minikanren notes.txt
Created Apr 15, 2013
Notes from @swannodette's MiniKanren seminar (very rough / unedited)
View minikanren notes.txt
four primitives: run*, ==, conde, fresh
(run* (q)
(== q #t))
; for what values of q is q equal to true?
answer: q must also be #t, so
'(#t) ; answer comes back in a list
You can’t perform that action at this time.