This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |