Skip to content

Instantly share code, notes, and snippets.

View joelnitta's full-sized avatar

Joel Nitta joelnitta

View GitHub Profile
@joelnitta
joelnitta / t1_double_cast.R
Created January 24, 2024 08:59
Look for double-casted spells on T1
library(tidyverse)
library(magicr)
library(arrow)
# Download WOE replay data
woe_game_replay_file <- mr_download_17lands_file(
"WOE", "replay", "premier")
# Load WOE replay data
woe_game_replay <- arrow::open_csv_dataset(
@joelnitta
joelnitta / check_t1_cards_for_draft_id.R
Created January 24, 2024 08:18
Look for double-casted spells on T1 in a particular draft_id
library(tidyverse)
library(magicr)
library(arrow)
# Download WOE replay data
woe_game_replay_file <- mr_download_17lands_file(
"WOE", "replay", "premier")
# Load WOE replay data
woe_game_replay <- arrow::open_csv_dataset(
@joelnitta
joelnitta / check_cards_played_t1.R
Created January 23, 2024 01:50
Check the cards played on turn one of a Limited MtG game
# To install magicr
# pak::pkg_install("joelnitta/magicr")
library(tidyverse)
library(magicr)
# OP:
# I'm working on some WOE replay data for Premier Draft and I'm seeing some
# stuff I don't understand. On row-index 8541, user plays both "Bakery Raid" and
# "Welcome to Sweet Tooth" on turn one, which can't happen. The same happens on
@joelnitta
joelnitta / wr_by_rank.R
Last active January 21, 2024 07:11
Calculate 17lands win-rate by rank across sets
# To install magicr
# pak::pkg_install("joelnitta/magicr")
library(tidyverse)
library(magicr)
library(ggrepel)
# Win-rate by rank and set ----
# Define function to calculate win-rate by rank for a particular set
@joelnitta
joelnitta / list_proj_pkgs.R
Created January 5, 2019 08:54
List all functions and packages used by R scripts in a project
# List all functions and packages used by R scripts in a project.
library(NCmisc)
# IMPORTANT: Also load any libraries used by the project
# Make list of all functions by package
funcs <-
list.files(here::here(), pattern ="\\.R$", recursive = TRUE, full.names = TRUE) %>%
map(list.functions.in.file) %>%
flatten
@joelnitta
joelnitta / archive_twitter_friends.R
Created November 18, 2022 11:34
Archive a user's friends on twitter
library(rtweet)
# Initial authorization setup, only need to do once
# auth_setup_default() #nolint
# Authorize
auth_as("default")
# Set user name
user_name <- "PUT USER NAME HERE"
@joelnitta
joelnitta / archive_tweets.R
Created November 18, 2022 03:03
Archive a user's tweets
library(rtweet)
library(tidyverse)
# Initial authorization setup, only need to do once
# auth_setup_default() #nolint
# Authorize
auth_as("default")
# Set user name
@joelnitta
joelnitta / parse_ncbi_tax_record.R
Last active October 25, 2022 11:22
R code for extracting NCBI taxonomy data
library(tidyverse)
library(assertr)
# Define custom parsing function
#' Parse a single record from the NCBI taxonomy database
#'
#' The NCBI taxonomy database contains names in the `names.dmp` file.
#' A single record (corresponding to one `taxid`) looks like this:
#'
@joelnitta
joelnitta / start-dockerd.sh
Last active August 24, 2022 05:22
Start rootless docker daemon
#!/usr/bin/bash
# Start docker daemon in background
nohup dockerd-rootless.sh --experimental --storage-driver vfs >| dockerd.log 2>&1 &
# Save the process ID so we can kill it later
echo $! > dockerd.pid
@joelnitta
joelnitta / test.po
Created August 8, 2022 21:46
Test PO file for po4a
# SOME DESCRIPTIVE TITLE
# Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-08-08 07:55+0000\n"