Skip to content

Instantly share code, notes, and snippets.

@cboettig
cboettig / zenodo.R
Last active August 29, 2015 14:09
zenodo.R
library(httr)
endpoint <- oauth_endpoint(NULL, "authorize", "token", base_url = "https://zenodo.org/oauth")
myapp <- oauth_app("zenodo", key, secret)
zenodo_token <- oauth2.0_token(endpoint, myapp, scope=c("deposit:write+deposit:actions"))
#!/bin/bash
PORT=${PORT:=8787}
# Mac/Windows must get this from boot2docker
IP=${IP:="http://localhost"}
# Pull latest version? (Allowed to fail, in case of no internet etc)
docker pull rocker/rstudio || true
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cboettig
cboettig / Wordpress-greycite.html
Last active August 29, 2015 14:18
Wordpress links to greycite citation API
Cite this post: <a href="http://greycite.knowledgeblog.org/bib?uri=<?php echo get_permalink(); ?>"
>BibTex</a> <a href="http://greycite.knowledgeblog.org/ris?uri=<?php echo get_permalink(); ?>
">RIS</a>
<!-- Uses the Greycite API -->
@cboettig
cboettig / test.R
Created April 14, 2015 19:55
testing parallel dplyr::do
library("nycflights13")
library("dplyr")
library("mgcv")
by_dest <- flights %>% group_by(dest) %>% filter(n() > 100)
system.time(
by_dest %>% do(smooth = gam(arr_delay ~ s(dep_time) + month, data = .))
)
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
#!/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>'