Skip to content

Instantly share code, notes, and snippets.

Joshua Moller-Mara mm--

Block or report user

Report or block mm--

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mm--
mm-- / org-refile-hydra.el
Created Mar 9, 2017
Hydra for quickly refiling Org mode entries
View org-refile-hydra.el
;; Adapted from https://emacs.stackexchange.com/questions/8045/org-refile-to-a-known-fixed-location
(defun my/refile (file headline &optional arg)
"Refile to a specific location.
With a 'C-u' ARG argument, we jump to that location (see
`org-refile').
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--
mm-- / pdf-speedread-convert.sh
Last active Sep 22, 2017
Speed read PDFs with jetzt
View pdf-speedread-convert.sh
#!/bin/bash
# Convert a pdf to html, add Javascript for speed reading
#READPDFLOC="./readPDF" # Use this if you want to use a local version
READPDFLOC="https://cdn.rawgit.com/mm--/b47c2700b6c63f1598e4/raw/a96388cb3cf89b7a041a63f06a91c2953ee5731c/readPDF.js"
FILE="$1"
HTML="$(basename "$FILE" .pdf).html"
SAVEDDIR=`pwd`
@mm--
mm-- / rfid.py
Created Jul 13, 2015
Raspberry Pi RFID reading for Seeed Studio Mini 125Khz RFID module
View rfid.py
# 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--
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
#!/usr/bin/Rscript
## 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 :-)
library(rgl)
args <- commandArgs(trailingOnly = TRUE)
@mm--
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
#!/usr/bin/Rscript
## 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--
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
require(MASS)
require(mvtnorm)
## Probability of each cluster for each point
E.step <- function(X, phi, N) {
h <-
with(phi, do.call(cbind,
lapply(1:N, function(i)
@mm--
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
#!/usr/bin/Rscript
## Generate a color palette for an image using k-Means
## Joshua Moller-Mara
library(jpeg)
library(colorspace)
library(rgl)
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.