Skip to content

Instantly share code, notes, and snippets.

View Ryo-N7's full-sized avatar

Ryo Nakagawara Ryo-N7

View GitHub Profile
@JoGall
JoGall / fpl_xpts_draft_h2h.R
Created August 20, 2024 14:08
Expected Points (xPts) for FantasyPL draft head-to-head league
# Calculate expected points for a FantasyPL draft, head-to-head league.
#
# Calculate expected points (xPts) and expected rank (xRank) for each
# team in a head-to-head draft league as the average points (i.e. 0, 1, 3)
# expected against all teams in that league each gameweek, not just the actual
# opponent.
#
# @param leagueid: integer
library(dplyr)
@tonyelhabr
tonyelhabr / gamestate-xgd.md
Last active June 16, 2024 04:04
The correct way to calculate xG difference by gamestate

Here's some fake data showing how shot logs might look for a soccer match.

library(tibble)
library(dplyr)

df <- tibble::tibble(
  shot_id = seq.int(1, 8),
  minute = c(7, 13, 25, 30, 41, 44, 58, 78), ## doesn't matter, just for illustrative purposes
library(tidycensus)
library(tidyverse)
options(tigris_use_cache = TRUE)
state_names <- c(state.name, "District of Columbia")
names(state_names) <- state_names
tictoc::tic()
age_maps <- map(state_names, ~{
@ikashnitsky
ikashnitsky / world-cup-odds.R
Last active December 26, 2022 07:37
Were there too many unlikely results in Qatar? -- https://ikashnitsky.github.io/2022/exceptional-world-cup
#===============================================================================
# 2022-12-25 -- ik-q
# World cups -- was Qatar that exceptional?
# Ilya Kashnitsky, [email protected], @ikashnitsky
#===============================================================================
library(tidyverse)
library(magrittr)
library(wdman)
library(RSelenium)
@veekaybee
veekaybee / chatgpt.md
Last active October 30, 2024 08:38
Everything I understand about chatgpt

ChatGPT Resources

Context

ChatGPT appeared like an explosion on all my social media timelines in early December 2022. While I keep up with machine learning as an industry, I wasn't focused so much on this particular corner, and all the screenshots seemed like they came out of nowhere. What was this model? How did the chat prompting work? What was the context of OpenAI doing this work and collecting my prompts for training data?

I decided to do a quick investigation. Here's all the information I've found so far. I'm aggregating and synthesizing it as I go, so it's currently changing pretty frequently.

Model Architecture

@koenvo
koenvo / README.md
Last active November 3, 2022 08:15

Cronjob and docker?

Some applications consist of multiple services. In those cases it can be useful to use a tool like docker-compose. With docker-compose you can define all your services within a single docker-compose yaml file, and add the file to your repository. This way you keep all services definition at a single place, with version control.

But what if you want to run a cronjob?

Cron on the host

One solution is to add a call to docker-compose to the crontab in the host system. In this example we would like to run a script called cleanup-old-files.py.

@jeroen
jeroen / app.R
Last active October 23, 2022 02:25
Reoder pdf with drag and drop in shiny
# https://twitter.com/henrikbengtsson/status/1583520708470067201
library(shiny)
library(sortable)
library(pdftools)
library(magick)
# The file to manipulate
pdffile <- tempfile(fileext = '.pdf')
download.file('https://www.uscis.gov/sites/default/files/document/forms/i-9-paper-version.pdf', pdffile)
# to create the plots in this Twitter thread: https://twitter.com/MeghanMHall/status/1560411406935138305
library(tidyverse)
library(ggrepel)
library(scales)
df1 <- txhousing %>%
filter(city %in% c("Houston","Austin")) %>%
group_by(year, city) %>%
summarize(avg = mean(median, na.rm = TRUE)) %>%
library(tidyverse)
## this r code is taking from here: https://github.com/mkearney/pkguse
read_r_files <- function(...) {
dirs <- unlist(list(...))
r <- unlist(lapply(dirs, list.files,
pattern = "\\.(R|Rmd|Rmarkdown|rmd|r|Rhistory)$",
recursive = TRUE,
full.names = TRUE,
all.files = TRUE))
@andrewbtran
andrewbtran / wpdatateam-ridge
Last active March 2, 2023 17:06
wpdatateam logo generator
# code from https://github.com/gkaramanis/aRtist/blob/main/genuary/2021/2021-3/2021-3.R
library(ggplot2)
library(dplyr)
library(magick)
library(ggridges)
# Read in image and convert to grayscale
img <- image_read(here::here("MRlWzfMH_400x400.jpg")) %>%
image_convert(colorspace = "gray")