Skip to content

Instantly share code, notes, and snippets.

View mbjoseph's full-sized avatar

Max Joseph mbjoseph

View GitHub Profile
@ito4303
ito4303 / stan_beta_proportion.Rmd
Created May 25, 2020 07:35
Using the beta_proportion distribution of Stan
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(rstan)
options(mc.cores = parallel::detectCores())
library(bayesplot)
```
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
@duncangh
duncangh / s3_to_pandas.py
Created April 7, 2019 03:01 — forked from jaklinger/s3_to_pandas.py
Read CSV (or JSON etc) from AWS S3 to a Pandas dataframe
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 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")
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)[]))
}
@felixgwu
felixgwu / fc_densenet.py
Created April 2, 2017 05:22
FC-DenseNet Implementation in PyTorch
import torch
from torch import nn
__all__ = ['FCDenseNet', 'fcdensenet_tiny', 'fcdensenet56_nodrop',
'fcdensenet56', 'fcdensenet67', 'fcdensenet103',
'fcdensenet103_nodrop']
class DenseBlock(nn.Module):
# 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))) +
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:
@rmaia
rmaia / phylostan_Ktrees.R
Last active May 23, 2017 12:55
Bayesian phylogenetic regression incorporating phylogenetic uncertainty by sampling from multiple trees (work in progress)
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')