This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "R Notebook" | |
output: html_notebook | |
--- | |
```{r} | |
library(rstan) | |
options(mc.cores = parallel::detectCores()) | |
library(bayesplot) | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I was drawn to programming, science, technology and science fiction | |
ever since I was a little kid. I can't say it's because I wanted to | |
make the world a better place. Not really. I was simply drawn to it | |
because I was drawn to it. Writing programs was fun. Figuring out how | |
nature works was fascinating. Science fiction felt like a grand | |
adventure. | |
Then I started a software company and poured every ounce of energy | |
into it. It failed. That hurt, but that part is ok. I made a lot of | |
mistakes and learned from them. This experience made me much, much |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~/usr/bin/env python | |
# | |
# Useful functions for xarray time series analysis | |
# (c) G. Maze, Ifremer | |
# | |
import numpy as np | |
import xarray as xr | |
import pandas as pd | |
from statsmodels.tsa.seasonal import seasonal_decompose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import pandas as pd | |
from io import BytesIO | |
bucket, filename = "bucket_name", "filename.csv" | |
s3 = boto3.resource('s3') | |
obj = s3.Object(bucket, filename) | |
with BytesIO(obj.get()['Body'].read()) as bio: | |
df = pd.read_csv(bio) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This example demonstrates running furrr code distributed on 2 AWS instances ("nodes"). | |
# The instances have already been created. | |
library(future) | |
library(furrr) | |
# Two t2.micro AWS instances | |
# Created from http://www.louisaslett.com/RStudio_AMI/ | |
public_ip <- c("34.205.155.182", "34.201.26.217") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fast_extract <- function(x, y, ...) { | |
## BEWARE no extract options are respected | |
raster::extract(x, sfpoly_cells(x, y)) | |
} | |
sfpoly_cells <- function(rast, sfpoly) { | |
## BEWARE, could be a big-data, this is not | |
## sparsely specified, so it's wasteful on memory, but fast (if you have the mem) | |
which(!is.na(fasterize::fasterize(sfpoly, rast)[])) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from torch import nn | |
__all__ = ['FCDenseNet', 'fcdensenet_tiny', 'fcdensenet56_nodrop', | |
'fcdensenet56', 'fcdensenet67', 'fcdensenet103', | |
'fcdensenet103_nodrop'] | |
class DenseBlock(nn.Module): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# devtools::install_github("ropensci/plotly") | |
library(plotly) | |
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf")) | |
# shared data will make the polygons "query-able" | |
ncsd <- crosstalk::SharedData$new(nc) | |
p <- ggplot(ncsd) + | |
geom_sf(aes(fill = AREA, text = paste0(NAME, "\n", "FIPS: ", FIPS))) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If 2fa is enabled on github switch to ssh instead of https on linux | |
1. generate an ssh keypair on your linux box | |
ssh-keygen -t {rsa|dsa} | |
2. add the public key to github: profile - settings - ssh keys | |
3. switch from https to ssh | |
Check your repo remote: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(rstan) | |
require(geiger) | |
require(MCMCglmm) | |
# load data | |
data(geospiza) | |
dat <- geospiza$geospiza.data | |
# create fake sample of trees | |
tr <- drop.tip(geospiza$geospiza.tree, 'olivacea') |
NewerOlder