Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Kleinschmidt kleinschmidt

View GitHub Profile
@kleinschmidt
kleinschmidt / reftex-markdown.el
Last active May 9, 2020
Insert markdown (pandoc-citeproc) formatted citations using RefTeX
View reftex-markdown.el
;; reftex in markdown mode
;; if this isn't already set in your .emacs
(setq reftex-default-bibliography '("/path/to/library.bib"))
;; define markdown citation formats
(defvar markdown-cite-format)
(setq markdown-cite-format
'(
(?\C-m . "[@%l]")
@kleinschmidt
kleinschmidt / fignos.Rmd
Last active Mar 26, 2016
pandoc-fignos and RMarkdown
View fignos.Rmd
---
title: "You kids play nice now"
output:
html_document:
keep_md: true
md_extensions: +implicit_figures
pandoc_args:
- --filter
- pandoc-fignos
references:
@kleinschmidt
kleinschmidt / pre-push
Last active Aug 29, 2015
A pre-push hook to automatically publish to github pages every time you push.
View pre-push
#!/bin/bash
# drop this in .git/hooks/, and chmod +x .git/hooks/pre-push
# store current branch
cur_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $cur_branch == "gh-pages" ]]
then
# bail out if we're trying to push the gh-pages branch (to prevent infinite loop)
exit 0
else
@kleinschmidt
kleinschmidt / input.R
Created Jan 28, 2015
converting factor to character after rowwise()
View input.R
library(dplyr)
data.frame(a=factor(c('10', '20', '30', '40'))) %>%
mutate(b=as.character(a)) %>%
rowwise() %>%
mutate(c=as.character(a)) %>%
str
@kleinschmidt
kleinschmidt / aws_creds.json
Last active Aug 29, 2015
Tiny demo of using Amazon SQS to listen to notifications from Mechanical Turk. Run `npm install` to get dependencies.
View aws_creds.json
{
"accessKey": "your access key",
"secretKey": "your secret key"
}
@kleinschmidt
kleinschmidt / qqplot.jl
Last active Aug 29, 2015 — forked from johnmyleswhite/qqplot.jl
QQ plots in Julia with Gadfly (based on Vega example)
View qqplot.jl
using Stats, Distributions, Gadfly
import Gadfly.ElementOrFunction
# First add a method to the basic Gadfly.plot function for QQPair types (generated by Distributions.qqbuild())
Gadfly.plot(qq::QQPair, elements::ElementOrFunction...) = Gadfly.plot(x=qq.qx, y=qq.qy, Geom.point, Theme(highlight_width=0px), elements...)
# Now some shorthand functions
qqplot(x, y, elements::ElementOrFunction...) = Gadfly.plot(qqbuild(x, y), elements...)
qqnorm(x, elements::ElementOrFunction...) = qqplot(Normal(), x, Guide.xlabel("Theoretical Normal quantiles"), Guide.ylabel("Observed quantiles"), elements...)
@kleinschmidt
kleinschmidt / histogram_woes.ipynb
Created Aug 3, 2014
Problems with Geom.histogram in Gadfly
View histogram_woes.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kleinschmidt
kleinschmidt / clean-library-auto.plist
Last active Oct 30, 2016
Make Mendeley, BibTeX, and apacite play nicely together by removing URL and month entries. Apacite lumps journal articles and newspaper/magazine articles in the same class, and always prints a month if it's provided. This gist has a shell script that strips this info out and a launchd handler that watches the auto-exported .bib file and runs the…
View clean-library-auto.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>auto-clean-mendeley-library</string>
<key>ProgramArguments</key>
<array>
<string>/Users/dkleinschmidt/Documents/papers/clean-library-auto.sh</string>
</array>
@kleinschmidt
kleinschmidt / concat_results_unique_assignments.sh
Last active Jan 4, 2016
Bash script which combines multiple (possibly redundant) .results files returned by Amazon Mechanical Turk's command line tools.
View concat_results_unique_assignments.sh
#!/bin/bash
# Author: Dave Kleinschmidt
#
#!/bin/bash
# Author: Dave Kleinschmidt
#
# concatenate all *.results files in the directory, printing one line
# per unique assignment id (first encountered). NOTE: the header isn't
@kleinschmidt
kleinschmidt / mod_to_table.R
Created Jan 13, 2014
Code to turn lmer models into a nice latex table. Specify model object or coefficients. Based on functions by Judith Degen (modified by Florian Jaeger): http://hlplab.wordpress.com/2010/06/15/r-code-for-latex-tables-of-lmer-model-effects/
View mod_to_table.R
mod.to.table <- function(mod.all=NA, prednames=NA, pred_name_subs=NA, file="",
coefs=as.data.frame(summary(mod.all)@coefs),
...) {
if (is.na(prednames)) {
if (is.na(pred_name_subs)) {
prednames <- row.names(coefs)
} else {
prednames <- str_replace_multi(row.names(coefs), pred_name_subs, replace.all=T)
}
}
You can’t perform that action at this time.