Skip to content

Instantly share code, notes, and snippets.

Single-round, multiple person Prisoner's Dilemma.
I want to maximize my payout.
If I choose `c` and everyone else choses `d` then I get `0`.
```{r}
[core]
pager = less -F -X
[alias]
lg = log --first-parent --graph --pretty=format:'%C(yellow)%h%Creset -%C(auto)%d%Creset %s %C(cyan)(%cr) %Cresetby %C(bold blue)%aN%Creset' --abbrev-commit
# source: https://www.r-bloggers.com/lotka-volterra-model%C2%A0%C2%A0intro/
library(deSolve)
LotVmod <- function (Time, State, Pars) {
with(as.list(c(State, Pars)), {
dx = x * (alpha - beta * y)
dy = -y * (gamma - delta * x)
return(list(c(dx, dy)))
})
}
from siuba.siu import strip_symbolic, _
import pandas as pd
d = pd.DataFrame({'a':[1], 'b':[1]})
call = _.a + _.b
call(d)
# dynamically objects to completion
class Shape3():
area = 1
perimeter = 1
location = 1
shape_dict = {}
def __getitem__(self, key):
if hasattr(self, key):
# References:
# https://ipython.readthedocs.io/en/stable/config/integrating.html
# https://stackoverflow.com/questions/17974777/tab-complete-dictionary-keys-in-ipython
class Shape2():
area = 1
perimeter = 1
location = 1
def __getitem__(self, key):
---
title: "test"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{test}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r, include = FALSE}
library(dplyr)
library(janeaustenr)
library(tidytext)
library(tidylo)
library(ggplot2)
tidy_bigrams <- austen_books() %>%
unnest_tokens(bigram, text, token = "ngrams", n = 2)
# bigrams across books
library(sagemaker)
s3_bucket()
#> [1] "sagemaker-us-east-2-495577990003"
tune <- sagemaker_attach_tuner("xgboost-191114-1954")
sagemaker:::model_artifact_s3_path(tune$model_name)
#> [1] "s3://sagemaker-us-east-2-495577990003/models/xgboost-191114-1954-002-e66e00d3/output/model.tar.gz"
# https://github.com/tmastny/sagemaker/blob/4d64375bdf4019cc0bf82a7ff4d6d97ea134f103/R/install.R#L29
library(stringr)
library(git2r)
library(magrittr)
print.github_url <- function(x, ...) {
cat(x)
invisible(x)
}