Skip to content

Instantly share code, notes, and snippets.

View sckott's full-sized avatar
😸

Scott Chamberlain sckott

😸
View GitHub Profile
@dfalster
dfalster / Glopnet.R
Last active February 10, 2023 09:02
Simple example of reproducible research, using global leaf traits database
library(xlsx)
library(smatr)
# get data, from publication Wright et al 2004. DOI: [10.1038/nature02403](http://doi.org/10.1038/nature02403)
download.file("http://www.nature.com/nature/journal/v428/n6985/extref/nature02403-s2.xls", "wright-2004.xls")
dat.Wright <- read.xlsx2("wright-2004.xls", sheetIndex=1, startRow=11, stringsAsFactors=FALSE, check.names=TRUE)
## Clean data
dat.Wright <- dat.Wright[names(dat.Wright) != " "] # Drop blank columns
for(v in c("log.LMA","log.LL"))
@sckott
sckott / ropensci_parallel.md
Last active March 21, 2016 17:03
example parallel workflow with an rOpenSci package

Example parallel workflow

In this example, we use the rgbif package to search for occurrence (lat/long) data for 1000 species

Install and load rgbif

install.packages("rgbif")
library("rgbif")
@lfender6445
lfender6445 / gist:9919357
Last active May 13, 2025 16:00
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@kevinushey
kevinushey / R_IsNA.cpp
Last active March 3, 2019 01:29
Comparing methods of checking whether a value is NA
// run me by installing Rcpp and calling sourceCpp on this file
#include <Rcpp.h>
using namespace Rcpp;
// some initial stuff borrowed from R sources
#ifdef WORDS_BIGENDIAN
static const int hw = 0;
static const int lw = 1;
@hubgit
hubgit / pmc-open-access-eutils.txt
Last active June 3, 2019 14:26
Useful URLs for working with the PMC Open Access Subset via EUtils
Search PubMed for articles in the PMC Open Access Subset for which free full text (i.e. XML) is available:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmode=xml&term=pubmed+pmc+open+access%5Bfilter%5D+AND+free+full+text%5Bfilter%5D
Find the PMCID for an article by PMID:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=pubmed&db=pmc&retmode=xml&linkname=pubmed_pmc&id=24191168
Fetch full text article XML from PMC by PMCID:
http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&id=3804407
A PMC article for which the full text XML is not available:
@chengyin
chengyin / linkedout.js
Last active July 11, 2021 15:23
Unsubscribe all LinkedIn email in "one click". For an easier to use version, you can check out the bookmarklet: http://chengyin.github.io/linkedin-unsubscribed/
// 1. Go to page https://www.linkedin.com/settings/email-frequency
// 2. You may need to login
// 3. Open JS console
// ([How to?](http://webmasters.stackexchange.com/questions/8525/how-to-open-the-javascript-console-in-different-browsers))
// 4. Copy the following code in and execute
// 5. No more emails
//
// Bookmarklet version:
// http://chengyin.github.io/linkedin-unsubscribed/
@aschweer
aschweer / scopus-citecounts.js
Created October 1, 2013 01:06
Scopus citation counts in DSpace xmlui
document.write('<script type="text/javascript" src="http://api.elsevier.com/javascript/scopussearch.jsp"> </' + 'script>');
callbackCitedbycount = function(){
if (sciverse.areSearchResultsValid()) {
var resultObj = sciverse.getSearchResults();
if (resultObj.returnedResults >0) {
citedbycount = resultObj.results[0].citedbycount;
eid = resultObj.results[0].eid;
if (citedbycount > 0) {
citeHtml = '<span class="bold">Scopus times cited</span>:</span> ';
@ramnathv
ramnathv / README.md
Last active April 8, 2022 11:17
Parser to Convert Markdown to CTV file.

This is a proof-of-concept of a parser to convert a markdown file to a ctv file, that is required for task views. The basic idea is to use a combination of YAML and markdown sections in the md file, parse it and convert it into a payload, and render it using a template as specified by the ctv package.

Structure of Markdown File

---
name: Working with data on the web
maintainer: Scott Chamberlain, Karthik Ram, Christopher Gandrud
email: scott at ropensci.org
version: 2013-09-17
@andrewburgess
andrewburgess / bootstrap-infiniteScroll.js
Last active January 24, 2024 23:49
Twitter Bootstrap plugin that enables infinite scrolling
/* ============================================
* bootstrap-infiniteScroll.js
* ============================================ */
!function ($) {
'use strict';
var InfiniteScroll = function (el, options) {
this.$element = $(el);
this.$data = $(el).data();
this.$options = options;
@hadley
hadley / html.r
Last active December 18, 2015 03:58
# We first start by creating a way of escaping the characters that have special
# meaning for html, while making sure we don't end up double-escaping at any
# point. The easiest way to do this is to create an S3 class that allows us to
# distinguish between regular text (that needs escaping) and html (that
# doesn't).
#
# We then write an escape method that leaves html unchanged and escapes the
# special characters (&, <, >) in ordinary text. We also add a method for lists
# for convenience