Skip to content

Instantly share code, notes, and snippets.

View saulshanabrook's full-sized avatar
🏊

Saul Shanabrook saulshanabrook

🏊
View GitHub Profile
{-|
> ```
Consider a simple model for whether a person has the flu or not. Let F=1
indicate that a person has the flu and F=0 indicate that they don't have the
flu. Let C=1 indicate that the person has a cough and C=0 indicate that they
don't have a cough. Let M=1 indicate that the person has muscle pain and M=0
indicate that they don't have muscle pain. Assume that C and M are conditionally
independent given F so that the probability model is
P(C=c,M=m,F=f)=P(C=c|F=f)P(M=m|F=f)P(F=f).
Suppose that we ask two different doctors to supply probabilities for this model
@saulshanabrook
saulshanabrook / script.sh
Created June 20, 2016 15:04
linting lisp files
$ emacs -Q --batch --eval '(add-to-list \'load-path "~/installs/slime")' --eval '(setq inferior-lisp-program (executable-find "sbcl"))' --eval '(require \'slime-autoloads)' --eval '(require \'slime)' --eval '(slime-setup)' --eval '(slime)' --eval '(while (not (slime-connected-p)) (sit-for 1))' --eval '(require \'json)' --eval '(princ (json-encode (second (slime-eval `(swank:compile-file-for-emacs "src/graph.lisp" t)))))' | jq
Polling "/var/folders/xl/z_j_yt_s5z18y3zdqg24tn180000gn/T/slime.20749" .. 1 (Abort with `M-x slime-abort-connection'.)
Polling "/var/folders/xl/z_j_yt_s5z18y3zdqg24tn180000gn/T/slime.20749" .. 2 (Abort with `M-x slime-abort-connection'.)
Connecting to Swank on port 58411..
Connected. Hack and be merry!
{
"message": [
"undefined variable: NODE",
"severity",
"warning",
@saulshanabrook
saulshanabrook / test.clj
Last active August 2, 2016 14:47
run on github.com/saulshanabrook/search-in-clojure
(require '[search.core])
(require 'plumbing.fnk.schema)
(require 'plumbing.fnk.pfnk)
(require '[plumbing.graph :as g])
(require 'rhizome.viz)
(require '[search.utils :as utils])
(def g_ (:final-graph (g/run search.core/config->run-graph (search.core/->config {:graph-symbols '(search.graphs.problems.push-sr/plus-six-graph search.graphs.algorithms.genetic/graph)}))))
@saulshanabrook
saulshanabrook / README.md
Created October 19, 2016 14:20
Saving Web Crypto Keys using indexedDB

This is a working example on how to store CryptoKeys locally in your browser. We are able to save the objects, without serializing them. This means we can keep them not exportable (which might be more secure?? not sure what attack vectors this prevents).

To try out this example, first make sure you are in a browser that has support for async...await and indexedDB (latest chrome canary with chrome://flags "Enable Experimental Javascript" works). Load some page and copy and paste this code into the console. Then call encryptDataSaveKey(). This will create a private/public key pair and encrypted some random data with the private key. Then save both of them. Now reload the page, copy in the code, and run loadKeyDecryptData(). It will load the keys and encrypted data and decrypt it. You should see the same data logged both times.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saulshanabrook
saulshanabrook / clojush.proto
Last active February 4, 2017 21:04
schema for all data generated during a clojush run, in protocal buffer format https://developers.google.com/protocol-buffers/
message Run {
required Configuration config = 1;
repeated Generation generations = 2;
}
message Configuration {
required string problemFile = 1;
// arguments are stored as EDN export of clojure types
required map<string, string> arguments = 2;
@saulshanabrook
saulshanabrook / main.go
Created April 27, 2017 01:50
for spark streaming multiplex
package main
import (
"fmt"
"io"
"log"
"net"
"os"
"github.com/djherbis/bufit"
@saulshanabrook
saulshanabrook / README.md
Created June 2, 2017 18:30
Magic kubernetes setup for mac

Install

# kubernetes
brew cask install minikube
minikube start

# helm
brew install kubernetes-helm
helm init
@saulshanabrook
saulshanabrook / event_based.clj
Created July 1, 2017 16:13
random ideas for clojush logging
(ns clojush.log
(require [plumbing.graph :as graph]
[plumbing.core :as plumbing]
[plumbing.map :as map]
[plumbing.fnk.pfnk :as pfnk]
[lazy-map.core :as lazy-map]))
(defmacro lazy-map-self
[map]
`(do
@saulshanabrook
saulshanabrook / utils.clj
Created July 29, 2017 19:35
clojure utils
(defn map-vals-w-keys
"Takes each [k v] in map m and changes it to [k (f k v)] "
[f m]
(into {}
(for [[k v] m]
[k (f k v)])))