Skip to content

Instantly share code, notes, and snippets.

View dwbapst's full-sized avatar

David Bapst dwbapst

  • College Station, TX
View GitHub Profile
@dwbapst
dwbapst / simulations.md
Last active June 29, 2021 19:00
Calculating The Chances for Catching Perfect IV Pokemon in Pokemon GO using Brute Force Simulations of Catching and Purification of Shadow Pokemonn
nruns <- 1000000 # one million runs

probability of getting a perfect wild pokemon without weather boosting

minIV <- 0
maxIV <- 15

perfects <- 0
for(i in 1:nruns){

pokemon <- sample(x = minIV:maxIV, size = 3, replace = TRUE)

@dwbapst
dwbapst / paleotree_MEE_blogPost.md
Last active September 29, 2020 15:29
MEE Blog Post for Bapst 2012 paleotree

paleotree in Methods in Ecology and Evolution: A Retrospective

David Bapst

Texas A&M University

dwbapst@tamu.edu

How I Ended Up Writing About My R Package in Methods in Ecology and Evolution Back In 2012

@dwbapst
dwbapst / Programming_borrowReuseSteal_09-21-20.md
Last active September 22, 2020 12:52
Programming and How To Use Code from Other People in Your Code

Programming and How To Use Code from Other People in Your Code

In programming, we often "borrow, reuse or steal" other people's code. This can make the line between what is plagiarized work and what is original work unclear. So, let's dive in a little to how code is reused, and what proper reuse and attribution look like.

Essentially, All Programming is Borrowing

First, all programming depends on previous programming: the code you will be write in this class (and pretty much any other data science class) relies on a language (R, Python, Java, etc) with a wide number of commands, and the commands available in the languages are what make the language useful. (In R, and many other languages, we refer to 'functions', not commands.) Those 'functions' themselves are pre-packaged segments of code that we can call upon by simply uttering the necessary command -- and they were written by previous developers. So, anyone who develops using such programming languages automatically relies on other people's work

@dwbapst
dwbapst / persistent_rb_eng.R
Created December 16, 2019 21:23
trying to make a persistent rb 12-16-19
# persistent_rb_eng_via_nohup.R
# to initiate rb:
mkfifo in_revbayes
# nohup rb <in_revbayes >out.txt &
# to run a sample of code (here 'x = 3+111')
# (echo -e "x = 3+111\n" && cat) > in_revbayes &
@dwbapst
dwbapst / nesting_species_predictions_remove_oddish_plus_some_gen_5_10-03-19.R
Last active October 3, 2019 13:08
Pokemon GO nest migration table - oddish removed, with gen 5 and no Eevee - 10-03-19
# Pokemon GO nest migration table - oddish removed, with gen 5 and no Eevee - 10-03-19
# taxa in full nesting list not in NEW nesting list
removeTaxaNew <- c("Oddish", "Eevee")
# taxa in full nesting list not in OLD nesting list
# this is often an empty set because
# the nesting list was fully utilized before an event
# if full list before migration, just do `""`
@dwbapst
dwbapst / NAPC_2019_dance_playlist.csv
Created July 1, 2019 20:19
Phoebe Cohen's Playlist, Coverted to Plaintext
I Gotta Feeling The Black Eyed Peas THE E.N.D. (THE ENERGY NEVER DIES) 4:49
Party Rock Anthem LMFAO, Lauren Bennett, GoonRock Sorry For Party Rocking 4:22
On The Floor - Radio Edit Jennifer Lopez, Pitbull On The Floor 3:50
Good Feeling Flo Rida Wild Ones 4:08
Just Dance Lady Gaga, Colby O'Donis The Fame Monster (Deluxe) 4:01
TiK ToK Kesha Animal (Expanded Edition) 3:19
Hey Ya! OutKast Speakerboxxx/The Love Below 3:55
Dancing On My Own - Radio Edit Robyn Body Talk 4:38
Call Your Girlfriend Robyn Body Talk 3:47
Run the World (Girls) Beyoncé 4 3:56
@dwbapst
dwbapst / bathyplot_rayshader_marmap_example-GoA.R
Last active February 25, 2024 18:20
Plotting a cool Rotatable 3D Bathymetric + Elevation Cube Using rayshader and marmap
## To install the latest version from Github:
# install.packages("devtools")
# devtools::install_github("tylermorganwall/rayshader")
## also marmap
# install.packages("marmap")
## load these libraries (?)
# library(rayshader)
# library(marmap)
## now just imported...
@dwbapst
dwbapst / remove_pika_aipom_05-06-19.R
Created May 7, 2019 14:01
Nest Migration Script 05-06-19
filename <- "remove_pika_aipom"
# remove taxa
removeTaxa <- c("Pikachu", "Aipom")
####################################
###################################
@dwbapst
dwbapst / Cal3_minMax_problem.R
Created April 22, 2019 18:52
Script from Armin showing that "terminal branches" are being included in dating of trees
library(paleotree)
#Simulate some fossil ranges with simFossilRecord
set.seed(444)
record<-simFossilRecord(p=0.1, q=0.1, nruns=1,
nTotalTaxa=c(30,40), nExtant=0)
taxa<-fossilRecord2fossilTaxa(record)
#simulate a fossil record with imperfect sampling with sampleRanges
rangesCont <- sampleRanges(taxa,r=0.5)
@dwbapst
dwbapst / make_78taxon_phylopic_tree.R
Last active March 15, 2019 21:42
Code for Plotting a Nice 78-Taxon Phylogeny with Stratigraphic Ranges, Upward Orientation, Phylopics, White Foreground Color with Black Background, etc
devtools::install_github("dwbapst/paleotree", ref="dev_refinedphylopicfun")
library(paleotree)
taxaSeventyEight <- c(
"Archaeopteryx", "Pinus", "Procoptodon", "Olenellus", "Eldredgeops",
"Quetzalcoatlus", "Homo", "Tyrannosaurus", "Triceratops", "Giraffa",
"Bolivina", "Cancer", "Dicellograptus", "Dunkleosteus", "Solanum",
"Anomalocaris", "Climacograptus", "Halysites", "Cyrtograptus",
"Procoptodon", "Megacerops", "Moropus", "Dimetrodon", "Lingula",