Skip to content

Instantly share code, notes, and snippets.

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

Sara Burke saralilyb

🤷‍♀️
View GitHub Profile
@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 / 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 / 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))
is <- 12/2 # in units on the drawn grid, NOT pixels
relvals <- c(9, 25, 41, 59, 75, 91)
incvals <- c(9, 25, 41, 59, 75, 91)
imagelist <- list()
# loop through and make list of grobs using both
for (r in relvals) {
for (i in incvals) {
strvals <- paste("/Users/jtth/diss/RFCs/", r, "-", i, ".png", sep = "")
grob <- rasterGrob(readPNG(strvals), interpolate = FALSE)
v <- list(img = grob, x = r, y = i)
@saralilyb
saralilyb / make-iso8601-timestamp.clj
Created February 4, 2018 23:27
makes an iso8601 timestamp using JUST CLOJURE WITHOUT SEVEN THOUSAND LIBRARIES COME ON KIDS LEARN HOW TO USE WHAT YOU HAVE
(defn maketimestamp
"makes iso8601 timestamp manually
(works pre java 8)
from https://stackoverflow.com/questions/3914404/how-to-get-current-moment-in-iso-8601-format-with-date-hour-and-minute"
[]
(let [tz (java.util.TimeZone/getTimeZone "UTC")
df (new java.text.SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss'Z'")]
(.setTimeZone df tz)
(.format df (new java.util.Date))))
@saralilyb
saralilyb / shh.rb
Created March 8, 2018 19:07 — forked from robinsloan/shh.rb
Disable RTs from all the people you follow on Twitter.
require "rubygems"
require "twitter"
# get these from apps.twitter.com
CONSUMER_KEY = "foo"
CONSUMER_SECRET = "bar"
OAUTH_TOKEN = "blee"
OAUTH_TOKEN_SECRET = "baz"
TWITTER_USER = "your_username" # needs to be the one associated with keys above
@saralilyb
saralilyb / uw-diss-title-page.tex
Last active March 26, 2018 16:55
Title page for a dissertation in LaTeX adhering to UW Madison's title page requirements
% adapted from https://texblog.org/2014/05/08/template-for-latex-phd-thesis-title-page/
% Fits University of Wisconsin's dissertation requirements:
% https://grad.wiscweb.wisc.edu/wp-content/uploads/sites/329/2017/11/new_phd_title_page.pdf
\begin{titlepage}
\thispagestyle{empty}
\begin{fullwidth}
\begin{center}
\centering
% %Thesis title
{\sc{\Large The Incidental Learning\\ of\\ Feature Distributions\\ in\\ Supervised Classification\par}}
@saralilyb
saralilyb / findPath.ts
Created September 12, 2018 15:22
BFS search example
const findPath = (targetNode, startNode = startWord, graph = wordlist ) => {
// source: https://books.google.com/books?id=GSBKDwAAQBAJ&pg=PA187&lpg=PA187&dq=bfs+lodash&source=bl&ots=FmkF1thzTu&sig=XjRtFH5vZH-mSRfIYowlwDdtIzM&hl=en&sa=X&ved=2ahUKEwjol-HZwbXdAhUDNd8KHW81Ao8Q6AEwCHoECAIQAQ#v=onepage&q=bfs%20lodash&f=false
// initialize the path to traverse
let travelledPath = [];
// mark the nodes that need to be visited breadthwise
let nodesToVisit = [];
// mark all visited nodes
@saralilyb
saralilyb / wordlist-snippet.json
Created September 13, 2018 14:46
Example of wordlist
{
"a-buff_t-fuchsia": [
"p-chestnut_a-buff_t-fuchsia",
"t-fuchsia_a-buff_t-fuchsia",
"s-limegreen_a-buff_t-fuchsia",
"a-buff_p-chestnut_t-fuchsia",
"a-buff_s-lilac",
"i-darkpink_t-fuchsia"
],
"i-darkpink_t-fuchsia": [
function gaborgenhelper(tilt, freq, title, sc, reso, phase, contrast, aspectratio)
if nargin < 4
reso = 400;
phase = 0;
sc = 50.0;
%freq = .07;
%tilt = 0;
contrast = 100.0;
aspectratio = 1.0;