Skip to content

Instantly share code, notes, and snippets.

Matthew Gilliard mjg123

Block or report user

Report or block mjg123

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 gist:8198a1311f4e8fa3b8376e93d24cafb1
public void handleRequest(ScrapeReq input) throws Exception {
FlowFuture<ScrapeResp> scrapes = currentFlow().invokeFunction("./scraper", input, ScrapeResp.class);
scrapes.thenCompose(resp -> {
List<ScrapeResp.ScrapeResult> results = resp.result;
List<FlowFuture<?>> pendingTasks = results
View Dockerfile-jdk10
FROM debian:sid-slim
ADD jdk-10-ea+39_linux-x64_bin.tar.gz /java
ENTRYPOINT ["/java/jdk-10/bin/jshell", "-q"]
mjg123 / flags.diff
Created Jan 16, 2018
JDK10 Ergonomics in container.
View flags.diff
--- host.flags 2018-01-16 13:09:27.257621324 +0000
+++ container.flags 2018-01-16 13:12:20.832503747 +0000
@@ -56,7 +56,7 @@
bool C1ProfileInlinedCalls = true {C1 product} {default}
bool C1ProfileVirtualCalls = true {C1 product} {default}
bool C1UpdateMethodData = true {C1 product} {default}
- intx CICompilerCount = 18 {product} {ergonomic}
+ intx CICompilerCount = 15 {product} {ergonomic}
bool CICompilerCountPerCPU = true {product} {default}
bool CITime = false {product} {default}
View poly.clj
;; A polynomial was produced by my GP to fit points generated by this function in the range [-10 <= a < 10]:
(def archetype (fn [a] (if (pos? a) 1 0)))
;; The results
(clojure.pprint/pprint (for [x (range -10 10)] (generated x)))
;; => (-0.00350264540310313
;; 0.0024697321715263917
;; -0.0034714670565933682
mjg123 /
Created Nov 16, 2016
TDD Demo Summary
2 is primereturn true;
3 is primereturn true;
4 is not primereturn n!=4;
5 is primereturn n!=4;
6 is not primereturn true unless n is even
7 is primereturn true unless n is even
8 is not primereturn true unless n is even
mjg123 / a_star.cljc
Last active Oct 6, 2016
Functional A*
View a_star.cljc
;; Rewrite of*_search_algorithm#Pseudocode in a functional way
#?(:cljs (def INFINITY 9007199254740991)) ;; Math.pow(2,53)-1
#?(:clj (def INFINITY Integer/MAX_VALUE))
(defn a*
([graph start goal heuristic] (a* graph start goal heuristic
#{start} #{} {}
{start 0} {start (heuristic start goal)}))
([graph start goal h
mjg123 / notes
Last active Dec 11, 2015
Lazy approach to approximating square roots in clojure using Newton-Raphson. For BrisFunctional.
View notes
line 21 sidesteps the fact that Math/abs doesn't work for clojure's Rational (ie fractional) datatype.
View test2.clj
(defn ensure-ns [ns-name]
(when-not (find-ns (symbol ns-name))
(intern (create-ns (symbol ns-name)) '*me* "never-seen")))
(the-ns (symbol ns-name)))
(defn eval-w-bindings [user-code ns-name user]
(let [my-ns (ensure-ns ns-name)]
(with-bindings {#'*ns* my-ns
(ns-resolve my-ns '*me*) user}
View test.clj
(when (not (find-ns 'mattermost))
(.setDynamic ;; <- This horrific interop into to counter
(intern (create-ns 'mattermost) ;; CLJ-951, which is a closed/wishlist bug reporting that
(with-meta '*me* {:dynamic true}) ;; <- this is actually not propagated fully (is, in fact, useless) :(
(defn eval-w-bindings [str user]
(binding [*ns* (create-ns 'mattermost)
mattermost/*me* user]
(clojure.core/refer 'clojure.core)
mjg123 / ajax.cljs
Created Jul 21, 2011
How to make a json(p) request from ClojureScript using jQuery
View ajax.cljs
(def jquery (js* "$"))
(defn show [msg]
(let [data-as-json ((js* "JSON.stringify") msg nil 4)]
((js* "alert") data-as-json)))
(defn make-js-map
"makes a javascript map from a clojure one"
(let [out (js-obj)]
You can’t perform that action at this time.