Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
# takes as arguments all the files to be uploaded, uploads with a tag of the timestamp which it uses to create the slideshow
# Note the backticks to get the return value of the function
MYTAG=`date +%Y%m%d%H%M%S`
flickr_upload --tag="$MYTAG" $*
# download the right format for flickr slideshows (from a raw gist of mine)
<html> <object width="400" height="300"> <param name="flashvars" value="offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fcboettig%2Ftags%2Funique_tag%2Fshow%2F&page_show_back_url=%2Fphotos%2Fcboettig%2Ftags%2Funique_tag%2F&user_id=46456847@N08&tags=unique_tag&jump_to=&start_index="></param> <param name="movie" value="http://www.flickr.com/apps/slideshow/show.swf?v=71649"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/slideshow/show.swf?v=71649" allowFullScreen="true" flashvars="offsite=true&lang=en-us&page_show_url=%2Fphotos%2Fcboettig%2Ftags%2Funique_tag%2Fshow%2F&page_show_back_url=%2Fphotos%2Fcboettig%2Ftags%2Funique_tag%2F&user_id=46456847@N08&tags=unique_tag&jump_to=&start_index=" width="400" height="300"></embed></object> </html>
require(ouch)
####### Anoles example ########
data(bimac) # ouch package Anolis sizes (from N. Lesser Antilles)
tree <- with(bimac,ouchtree(node,ancestor,time/max(time),species))
bm <- brown(log(bimac['size']),tree)
ou1 <- hansen(log(bimac['size']),tree,bimac['OU.1'],1,1)
ou3 <- hansen(log(bimac['size']),tree,bimac['OU.3'],1,1)
ou4 <- hansen(log(bimac['size']),tree,bimac['OU.4'],1,1)
pow <- power_between_models(ou2,ouLP, nboot=1000)
png("OU2vOULP.png")
plot(density(pow$null_dist), xlim=c(-40,40), lwd=3, main="OU.2 v OU.LP")
lines(density(pow$test_dist), xlim=c(-40,40), lwd=3, lty=2)
abline(v=-2*(ouLP@loglik-ou2@loglik), lwd=3, col="darkred" )
legend("topleft", c("sim under OU.2", "sim under OU.LP"), lty=c(1,2))
dev.off()
# Create a left-aligned title
# side = 3 means top margin
# adj = 0 means left align
# line= 1.2 moves the text up
plot(1:10, 1:10, yaxt="n", ylab="");
mtext("Title", side=3, adj=0, line=1.2, cex=2, font=2);
axis(2, las=1)
@cboettig
cboettig / socialR.R
Created November 29, 2010 21:50
Enable simulations to share status on social networks
## Error reporting
tweetError <- function(){
system(paste('hpc-autotweets "@cboettig runtime error"', sep=""))
}
options(error = tweetError)
## Reporting a finished run
##social reporting
gitcom <- system('git commit -a -m "autocommit"', intern=TRUE)[[1]]
@cboettig
cboettig / pdf2png.sh
Created December 15, 2010 19:11
convert all pdf to png
#!/bin/bash
# Convert all pdf to png
for f in *.pdf
do
convert "$f" "${f%.pdf}.png"
done
@cboettig
cboettig / flickr-gallery
Created January 6, 2011 19:27
shortcodes for the flickr-gallery wordpress plugin to include photos by date and tag
@cboettig
cboettig / S3S4.R
Created January 10, 2011 18:49
Using S3 and S4 classes in R
setOldClass("myS3Class")
setGeneric("foo", function(x, ...) standardGeneric("foo"))
foo =
function(x, ...)
UseMethod("foo")
foo.myS3Class =
@cboettig
cboettig / KingMarkovIsland.R
Created January 26, 2011 23:57
Demonstration of Metropolis algorithm
##########################################################
# King Markov, island dictator example
# this is a simple metropolis algorithm
num.visits <- 20000
population <- 1:10
current.island <- sample( 1:10 , size=1 )
visits <- {}
par(mfrow=c(2,1))
for ( i in 1:num.visits ) {
visits[i] <- current.island