Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Gilliard mjg123

View GitHub Profile
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
mjg123 / Convert.java
Last active May 9, 2018
A little class for re-writing Java method names when using `jaotc`
View Convert.java
public class Convert {
public static void main(String args[]) throws Throwable {
int i;
boolean inParams = false;
while ((i = System.in.read()) >= 0) {
switch (i) {
case ':':
continue; // skip
case '/':
if (!inParams) {
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
mjg123 / tdd.org
Created Nov 16, 2016
TDD Demo Summary
View tdd.org
TestImplementation
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
mjg123 / a_star.cljc
Last active Oct 6, 2016
Functional A*
View a_star.cljc
;; Rewrite of https://en.wikipedia.org/wiki/A*_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
View test2.clj
(defn ensure-ns [ns-name]
(when-not (find-ns (symbol ns-name))
(.setDynamic
(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 Var.java 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) :(
"foo")))
(defn eval-w-bindings [str user]
(binding [*ns* (create-ns 'mattermost)
mattermost/*me* user]
(clojure.core/refer 'clojure.core)
@mjg123
mjg123 / gist:cb544f2f6853df8d866c
Last active Aug 29, 2015
Diagnosing a gate failure using logstash.openstack.org
View gist:cb544f2f6853df8d866c

Recently we noticed that the "check-tempest-dsvm-multinode-full" job, which is non-voting in nova's check jobs, was failing in a new way.

Some notes about how the failure was diagnosed:

  1. Job is failing
  2. why? find a signature for the failure, eg
File "tempest/api/compute/admin/test_live_migration.py", line 116, in test_live_block_migration"
@mjg123
mjg123 / mc.py
Created Dec 1, 2014
classes using a decorator to store methods will be dependent on decorator ordering
View mc.py
import pprint
import six
captured_methods = {}
class MjgClass(object):
@classmethod
def decorated(cls):
global captured_methods
def decorator(f):
You can’t perform that action at this time.