Skip to content

Instantly share code, notes, and snippets.

View saralilyb's full-sized avatar
🤷‍♀️

Sara Burke saralilyb

🤷‍♀️
View GitHub Profile
@saralilyb
saralilyb / trailing-slash-middleware
Created June 12, 2017 21:52 — forked from dannypurcell/trailing-slash-middleware
Ring middleware fn. Removes a trailing slash from the uri before calling the handler.
(defn ignore-trailing-slash
"Modifies the request uri before calling the handler.
Removes a single trailing slash from the end of the uri if present.
Useful for handling optional trailing slashes until Compojure's route matching syntax supports regex.
Adapted from http://stackoverflow.com/questions/8380468/compojure-regex-for-matching-a-trailing-slash"
[handler]
(fn [request]
(let [uri (:uri request)]
(handler (assoc request :uri (if (and (not (= "/" uri))
@saralilyb
saralilyb / simplemde-react-reagent.cljs
Last active May 29, 2017 17:25
Reactive SimpleMDE component with reagent
(defn editor [text]
(let [dom-node (r/atom nil)]
(r/create-class
{:component-did-update
;; this is the draw code plus the update code
(fn [this old-argv]
(let [editor (js/SimpleMDE.
(clj->js
{:autofocus true
:spellChecker true
@saralilyb
saralilyb / genCoffeeDict.R
Created March 31, 2017 17:10
Generate a CoffeeScript dictionary using R
blockprint_training_dim1 <- function(rel, inc, boundary = 50) {
# right now this assumes rel = rotation and inc = spacing
isafep <- function(x) x < boundary # check if fep
isfep <- isafep(rel) # are we a fep?
cat("\t{\n") # begin block
cat("\t\tstimulus: gabgen(", rel,", ", inc, ")\n", sep = "") # code for generation
key_answer_val <- ifelse(isfep, 70, 78) # fep (f) if it's less than 50, n if more
cat("\t\tkey_answer: ", key_answer_val, "\n", sep = "") # which button is good?
text_to_use_correct <- ifelse(isfep, "fep_correct_text", "notfep_correct_text")
@saralilyb
saralilyb / compbf.R
Created March 26, 2017 12:01
compare bayesfactor models in R with the random baseline
# compares bayesfactor analyses relative to the last, which is the random only model (just participants)
compbf <- function(m) {
m[c(1:(length(m)-1))]/m[length(m)]
}
@saralilyb
saralilyb / compile-closure.sh
Created March 19, 2017 17:10
Shell script to compile javascript through Google Closure
#!/bin/sh
usage(){
echo "Usage: $0 inputfile.js closurecompiledfile.js"
exit 1
}
is_file_exits(){
local f="$1"
[[ -f "$f" ]] && return 0 || return 1

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@saralilyb
saralilyb / dice-mcmc.r
Created April 26, 2016 13:18
MCMC model of dice rolling: is a bastard sword better than a longsword (2nd Ed, BGII)
# 2d4 vs 1d8
samples <- 10000
# 2d4
m1d4 <- sample(1:4, samples, replace = TRUE)
m2d4 <- sample(1:4, samples, replace = TRUE)
bastard_sword <- m1d4 + m2d4
@saralilyb
saralilyb / .vimrc-after
Created March 13, 2016 17:54
Make vim feel like this century with hard tabs as 2 spaces, soft wrap at 80 columns, and hanging intents on soft wrapped text.
set linespace=4
set noexpandtab
set wrap
set linebreak
set breakindent
set briopt=shift:2
set shiftwidth=2
set tabstop=2
set textwidth=79
set columns=80
@saralilyb
saralilyb / minmax-numeric.js
Created February 29, 2016 22:18
Array Min and Max functions using NumericJS through mapreduce
arrmax = numeric.mapreduce('if(xi > accum) accum=xi;','-Infinity');
arrmin = numeric.mapreduce('if(xi < accum) accum=xi;','Infinity');
@saralilyb
saralilyb / rescale_core.coffee
Last active February 29, 2016 18:57
Rescales an array so all values lie between a and b, where m is the unscaled array's (potential) minimum value and M is the max. Requires the NumericJS library. Based on Gabriel Peyre's MATLAB code: http://www.mathworks.com/matlabcentral/fileexchange/5103-toolbox-diffc/content/toolbox_diffc/toolbox/rescale.m
rescale_core = (y, a, b, m, M) ->
y if M - m < .0000001
numeric.add(numeric.mul(b - a, numeric.div(numeric.sub(y, m), M - m)), a)