Skip to content

Instantly share code, notes, and snippets.

@noamross
noamross / pandocwithbib
Created May 22, 2012 02:35
This is my live preview script for a pandoc file
#!/bin/bash
text=`cat`
echo -E $text | grep -o '@\w*' | sort -n | uniq | sed -n 's/@\(.*\)/\\citation\{\1\}/p' >> ~/smallbib.aux
bibtool --preserve.key.case=on -s -d -x ~/smallbib.aux /Users/noamross/Dropbox/Public/library.bib -o ~/smallbib.bib
echo -E "$text" | pandoc -f markdown -t html --smart --mathjax --bibliography=/Users/noamross/smallbib.bib --csl=/Users/noamross/Dropbox/Public/pd/ecology.csl --template=/Users/noamross/Dropbox/Public/pd/noam.html --base-header-level=2
rm ~/smallbib.*
@noamross
noamross / pjt.md
Created May 22, 2012 02:55
pandoc jekyll template

$if(title)$ title: $title$ $endif$ $if(author)$ author: $author$ $endif$ $if(tags)$ tags: $tags$ $endif$

@noamross
noamross / gist:2832732
Created May 30, 2012 02:06
Convert/ google upload script
#!/bin/bash
filename="$TM_FILEPATH"
basename="${filename%.*}"
text=`cat `
echo -E $text | grep -o '@\w*' | sort -n | uniq | sed -n 's/@\(.*\)/\\citation\{\1\}/p' >> ~/smallbib.aux
bibtool --preserve.key.case=on -s -d -x ~/smallbib.aux /Users/noamross/Dropbox/Public/library.bib -o ~/smallbib.bib
@noamross
noamross / jsbookmarklet
Created August 8, 2012 17:45
A bookmarklet that takes you straight to the JSTOR pdf
javascript:(function() {window.location=window.location.toString().replace(/^http:\/\/www\.jstor\.org\/stable\/.*\/(.*?)$/,'http://www.jstor.org/stable/pdfplus/$1.pdf?acceptTC=true');}())
@noamross
noamross / organize_pdfs
Created October 5, 2012 16:21
Remove cover pages from PDFs and make links to sync recent additions
#!/bin/bash
# This script is set to run any time a new file is added to my "Papers" folder, using launchd
# 1 - Find papers with JSTOR or Science cover sheets and remove the first page
text1="kind:pdf Your use of the JSTOR archive indicates your acceptance of" #JSTOR papers
text2="kind:pdf is published weekly, except the last week in December" #Science papers
#Add more of these as you find text snippets that identify cover sheets from different publishers. Then add more loops belo
@noamross
noamross / bash.scpt
Created October 9, 2012 23:04
Run bash script from quicksilver
using terms from application "Quicksilver"
on process text _bashcom
do shell script "/bin/bash -ic '" & _bashcom & "'"
end process text
end using terms from
@noamross
noamross / BashGrowl.scpt
Created October 16, 2012 20:00
BashGrowl: Run Command in Bash and display output as Growl Notificaiton
# Save this in ~/Libary/Application Support/Quicksilver/Actions and relaunch
# Quicksilver. Then just enter a text bash command and activate "BashGrowl" in
# the second pane. I like it for todo.txt and system status calls.
using terms from application "Quicksilver"
on process text theCommand
set _text to do shell script "/bin/bash -ic " & quoted form of theCommand
try
tell application "System Events"
@noamross
noamross / proftable.R
Created November 12, 2012 19:09
Another way to view R profiling Data
proftable <- function(file) {
require(plyr)
sample.interval <- as.numeric(strsplit(readLines(file, 1), "=")[[1L]][2L])/1e+06
profdata <- as.matrix(read.table(file, header=FALSE, sep=" ", colClasses="character", skip=1, fill=TRUE, na.strings=""))
total.time <- nrow(profdata)*sample.interval
stacktable <- data.frame(table(aaply(profdata, 1, function(x) paste(rev(na.omit(x)), collapse=" > "))))
names(stacktable) <- c("Stack","PctTime")
stacktable$PctTime <- 100*stacktable$PctTime/nrow(profdata)
stacktable <- stacktable[order(stacktable$PctTime, decreasing=TRUE), c("PctTime", "Stack")]
rownames(stacktable) <- NULL
@noamross
noamross / fix.csv.R
Created November 19, 2012 21:49
Use R's native data editor to edit a CSV
#' Use the data editor for a CSV file
#'
#' This function loads a CSV file, lets the user edit it in the native data
#' editor, then re-saves it, prompting the user for a new name if desired.
#'
fix.csv <- function(file, new.name=TRUE, sep=",", comment.char="") {
tmpframe <- read.csv(file, sep=sep,quote="", colClasses="character",
stringsAsFactors=FALSE, comment.char="",
blank.lines.skip=FALSE, na.strings="")
tmpframe <- edit(tmpframe)
Noam Ross
---------
### 13-01-22 14:50:15
Abstract
========
Forest disease spreads through plant communities structured by species composition, age distribution, and spatial arrangement. I propose to examine the consequences of the interaction of these components of population structure on a model systems of *Phytophthora ramorum* invasion in California redwood forests. First, I will compare the dynamic behavior of a series of epidemiological models that include different configurations of population structures. Then I will fit these models to time-series data from a network of disease monitoring plots to determine what components of forest population structure are most important for prediction of disease spread. Using the most parsimoniuous models, I will determine optimal schedules of treatment to minimize the probability of disease outbreak.