Skip to content

Instantly share code, notes, and snippets.

link video files together
mencoder -forceidx -ovc copy -oac copy -o file.avi p1.avi p2.avi ...
vim map F3 to count number of printed words in tex file:
:map <F3> :w !detex \| wc -w<CR>
convert all pdfs to pngs:
for i in *.pdf; do convert "$i" "${i/.pdf}".png; done
PKG_CPPFLAGS=-Wall
PKG_LIBS=-lm -lgsl -lgslcblas
#include <gsl/gsl_siman.h>
/* set up parameters for this simulated annealing run */
#define N_TRIES 200 /* how many points do we try before stepping */
#define ITERS_FIXED_T 200 /* how many iterations for each T? */
#define STEP_SIZE 1. /* max step size in random walk */
#define K 1.0 /* Boltzmann constant */
#define T_INITIAL 0.01 /* initial temperature */
#define MU_T 1.003 /* damping factor for temperature */
#define T_MIN .0078
/**
* @file kde.c
* @author Carl Boettiger, <cboettig@gmail.com>
* @section DESCRIPTION
* Estimates the kernel density p(x) at a given value x from
* an array of sample points. Uses the default algorithm from
* the R langauge's 'density' function. Requires the GSL statistics
* library.
*
* @section LICENCE
#!/bin/sh
# how to upload images to flickr and create a mediawiki embeddable text
flickr_uploader tag="$1" > ids.txt
# grep -o returns only the matches to the regular expression
# of any amount (*) of numbers to an endline
# sed find/replaces the number string with the <flickr> tag
# and the "&" pastes the regexp match back in
grep -o [0-9]*$ ids.txt | sed '/[0-9]*/<flickr>&|t<\/flickr>'
<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>
#!/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)
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)