Skip to content

Instantly share code, notes, and snippets.

Josh Moller-Mara mm--

View GitHub Profile
mm-- / org-refile-hydra.el
Created Mar 9, 2017
Hydra for quickly refiling Org mode entries
View org-refile-hydra.el
;; Adapted from
(defun my/refile (file headline &optional arg)
"Refile to a specific location.
With a 'C-u' ARG argument, we jump to that location (see
Use `org-agenda-refile' in `org-agenda' mode."
(let* ((pos (with-current-buffer (or (get-buffer file) ;Is the file open in a buffer already?
(find-file-noselect file)) ;Otherwise, try to find the file by name (Note, default-directory matters here if it isn't absolute)
mm-- /
Last active Sep 22, 2017
Speed read PDFs with jetzt
# Convert a pdf to html, add Javascript for speed reading
#READPDFLOC="./readPDF" # Use this if you want to use a local version
HTML="$(basename "$FILE" .pdf).html"
mm-- /
Created Jul 13, 2015
Raspberry Pi RFID reading for Seeed Studio Mini 125Khz RFID module
# Raspberry Pi RFID reading for Seeed Studio Mini 125Khz RFID module
import serial, operator
rfid = serial.Serial("/dev/ttyAMA0")
rfid.baudrate = 9600
rfid.timeout = 2 # Need a timeout in case we read less than 5 bytes
def verify(data):
"""Check the validation bit (the last one) by XORing the first four bytes."""
ints = map(ord, list(data))
if (len(ints) != 5):
mm-- / asc-to-obj.R
Created Sep 5, 2014
Take a FreeSurfer ASCII format surface and convert to Wavefront .obj, unnecessarily rendering a rainbow-colored surface using rgl ;P
View asc-to-obj.R
## Josh Moller-Mara
## Take in an .asc file created with mris_convert
## (e.g. mris_convert lh.pial lh.pial.asc)
## and then convert it into a Wavefront OBJ.
## And also unnecessarily render it with rgl :-)
args <- commandArgs(trailingOnly = TRUE)
mm-- / lda-test.R
Created Aug 3, 2014
An attempt to use Latent Dirichlet Distribution to do topic modeling and clustering on text
View lda-test.R
## NOTE: This code got pretty messy, and is no longer meant to be run
## just as an Rscript.
## LDA test
## Josh Moller-Mara
## Take in a file with one "document" per line.
## Try to cluster them using Latent Dirichlet Allocation and select
## among models using DIC.
mm-- / mixture-models-em.R
Last active Mar 12, 2018
An example of clustering using Gaussian mixture models, fitted using Expectation-Maximization.
View mixture-models-em.R
## EM algorithm implementation
## Joshua Moller-Mara
## Probability of each cluster for each point
E.step <- function(X, phi, N) {
h <-
lapply(1:N, function(i)
mm-- / k-means-color.R
Created Nov 12, 2013
Create a color palette for xterm from a JPEG using k-means.
View k-means-color.R
## Generate a color palette for an image using k-Means
## Joshua Moller-Mara
args <- commandArgs(trailingOnly = TRUE)
plotPalette <- function(palette) {
barplot(rep(1,length(palette)), yaxt="n", col=palette)
You can’t perform that action at this time.