Skip to content

Instantly share code, notes, and snippets.

(comment
"The riddle is as follows:
Two numbers are chosen randomly, both are positive integers smaller than 100.
Sandy is told the sum of the numbers, while Peter is told the product of the numbers.
Then, this dialog occurs between Sandy and Peter:
Peter: I don't know the numbers.
Sandy: I don't know the numbers.
Peter: I don't know the numbers.
library(tidyverse)
library(rvest)
box_office <-
read_html("https://www.boxofficemojo.com/title/tt0389790/?ref_=bo_se_r_1") %>%
html_nodes("h3 + table") %>%
# Select "Europe, Middle East, and Africa" table only
.[[2]] %>%
html_table() %>%
janitor::clean_names() %>%
#' Helper functions for styling with ggtext
#'
#' @param text The text which should be styled
#' @param ... Style options. For example `color="red"`
#' @param tag HTML tag to apply to the text. Defaults to `span`
#'
#' @export
tagged_text <- function(text, ..., tag = "span") {
glue::glue("<{tag} style='{parse_style_options(...)}'>{text}</{tag}>")
}
@Torvaney
Torvaney / optapro-forum.md
Last active May 5, 2023 06:40
Links to OptaPro forum talks

OptaPro Forum talks

At some point StatsPerform unlisted all the Opta pro forum talks from YouTube, meaning they can only be accessed if you have the URL (i.e. they cannot be found through search).

Leave a comment or let me knwow on Twitter (DMs open) if you find any additional talks that aren't listed here.

2014

library(tidyverse)
sample_with_suspense <- function(...) {
result <- sample(list(...), 1)
cat_slowly <- slowly(cat, rate = rate_delay(1))
walk(c(rep(".", times = 10), paste0(result, "!\n")), cat_slowly)
}
sample_with_suspense("Pizza", "Burger")
# From: https://twitter.com/dirk_sch/status/1352194126654148618
library(purrr)
library(testthat)
fn <- function(xs) {
if (!is_list(xs) | length(xs) < 2)
return(xs)
f_xs <- map(xs, fn)
exec(f_xs[[1]], !!!f_xs[2:length(f_xs)])
@Torvaney
Torvaney / eng-football-highlights.md
Last active November 11, 2020 11:21
English-language football catch-up and highlights shows

A list of English-language football catch-up and highlights shows, available from the UK

Big 5

  • 🇬🇧 Premier League
    • MoTD (BBC iPlayer)
  • 🇩🇪 1. Bundesliga
    • Bt Sports' "Bundesliga Review"
  • 🇳🇱 Eredivisie
  • Premier Sports (£) (UK and RoI)
library(ggplot2)
library(ggsoccer)

pitch_custom_circle <- list(
  length = 106,
  width = 68,
  penalty_box_length = 16.5,
  penalty_box_width = 40.32,
  six_yard_box_length = 5.5,
class Just:
def __init__(self, value):
self.value = value
def __repr__(self):
return f'Just({self.value.__repr__()})'
def __eq__(self, other):
if isinstance(other, Just):
return self.value == other.value
FIZZBUZZ_SPEC = {
3: 'fizz',
5: 'buzz'
}
def fizzbuzz_item(x, spec=FIZZBUZZ_SPEC):
return ''.join(v for k, v in spec.items() if (x % k) == 0) or str(x)