Skip to content

Instantly share code, notes, and snippets.

View mathzero's full-sized avatar

Matt Whitaker mathzero

  • Imperial College London
View GitHub Profile
@sebkopf
sebkopf / README.md
Last active April 6, 2023 10:11
wolfram alpha from R

Wolfram Alpha API from R

The attached code file provides an easy basic interface to the Wolfram Alpha API. Inspired by the wolframalpha module available for Python.

source("wa_lib.R")

Initialize client

@primaryobjects
primaryobjects / server.R
Created February 2, 2016 22:26
Diabetes risk calculator. First shiny app made in R.
## Including the required R packages.
packages <- c('shiny')
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())))
}
library(shiny)
shinyServer(function(input, output) {
submit <- FALSE
@paulera
paulera / exploding-cards.md
Last active June 13, 2024 00:07
Exploding cards: Explodding Kittens variant, with regular playing cards

Exploding cards

This is a variant of the Exploding Kittens game rules, using regular playing cards

  • 1 deck: 3 to 8 players
  • 2 decks: up to 16 players

Objective

The last survivor wins the game. If you draw a Bomb card and don't have a Disarm card, you die.

Preparing the game

var timer=100;document.querySelectorAll("div > input[type='checkbox']:checked").forEach((interest) => {setTimeout(function(){interest.click()},timer);timer+=2000;});
# Install and load required packages
install.packages("needs")
library(needs)
needs(tidyverse, magrittr, animation, pdftools, png, scales)
# Function that extracts data from Google Mobility PDFs
process_google_mobility <- function(country_code, start_date, end_date){
# Convert first page of PDF into high-res PNG
pdf_convert(paste0("https://www.gstatic.com/covid19/mobility/",end_date,"_",country_code,"_Mobility_Report_en.pdf"), format = "png", pages = 1, dpi = 300, filenames = "IMG1.png")