This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The Strategy Unit C&C, 2025-11-06: collaborating using Github | |
| ## Focus | |
| This is about using the GitHub interface for [pull requests (PRs)](https://docs.github.com/en/pull-requests) from the perspective of the assignee (submitter) and reviewer. | |
| I'm concentrating on a pull request to a repository that you have access to, e.g. in [The-Strategy-Unit GitHub organisation](https://github.com/The-Strategy-Unit/). | |
| ## Why? | |
| Pull requests are important because they help: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env -S uv run | |
| # /// script | |
| # requires-python = ">=3.12" | |
| # dependencies = [ | |
| # "datetime", | |
| # "httpx", | |
| # ] | |
| # /// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ui <- bslib::page_fillable( | |
| bslib::card( | |
| bslib::card_header("Gacha"), | |
| shiny::textOutput("rolled_details"), | |
| shiny::textOutput("rolled_emoji"), | |
| shiny::actionButton("btn_roll", "Roll!") | |
| ), | |
| bslib::card( | |
| bslib::card_header("Collection"), | |
| shiny::tableOutput("dex") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # hex sticker for {aftables}: | |
| # https://github.com/best-practice-and-impact/aftables | |
| # having installed the Free Sans font: | |
| # https://www.fontspace.com/freesans-font-f13276 | |
| # and installed {gex}: | |
| remotes::install_github("matt-dray/gex") | |
| # and {ggplotify}: | |
| install.packages("ggplotify") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set.seed(123) | |
| n <- 5 | |
| scheme <- paste("Scheme", 1:n) | |
| mitigator <- paste("Mitigator", LETTERS[1:n]) | |
| combos <- tidyr::crossing(scheme, mitigator) | |
| nrows <- nrow(combos) | |
| dat <- combos |> | |
| dplyr::mutate( | |
| mitigator_group = dplyr::if_else( | |
| stringr::str_detect(mitigator, " [ABC]$"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Calculate how many plots will be produced | |
| count_plots <- function(df, var) { | |
| length(unique(df[[var]])) | |
| } | |
| # Plot faceted chart, save with height dependent on plot count | |
| write_responsive_facets <- function( | |
| df, | |
| var = "species", | |
| plot_count = count_plots(df, var), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # {nara} by Mike Cheng: https://coolbutuseless.github.io/package/nara/index.html | |
| # Kenney by Kenney: https://www.kenney.nl | |
| # Read png tiles | |
| tile_paths <- list.files( | |
| "~/Desktop/kenney/kenney_tiny-dungeon/Tiles", | |
| pattern = ".png$", | |
| full.names = TRUE, | |
| recursive = TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 1. Generate temporary Excel files ---- | |
| # Make a temporary spreadsheet with named sheets | |
| make_temp_xlsx <- function(sheet_names) { | |
| wb <- openxlsx2::wb_workbook() | |
| for (sheet in sheet_names) wb <- wb |> openxlsx2::wb_add_worksheet(sheet) | |
| temp <- openxlsx::temp_xlsx() | |
| openxlsx2::wb_save(wb, temp) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Convenience Function: Read a (Zipped) JSON File from an Azure Container | |
| #' | |
| #' @param container A blob_container/storage_container object. Probably | |
| #' generated by [connect_to_container]. | |
| #' @param file Character. Path to file within the container named by | |
| #' `container`. | |
| #' | |
| #' @return A list. | |
| #' @export | |
| #' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| generate_num_format <- function(number = 8634567.890) { | |
| num_val <- number %/% 1 | |
| num_dp <- number %% 1 | |
| num_split <- strsplit(as.character(number), "\\.")[[1]] | |
| n_dp <- nchar(num_split[2]) | |
| num_commas <- scales::number(as.numeric(num_val), big.mark = ",") | |
| fmt_out <- gsub("[[:digit:]]", "#", num_commas) |
NewerOlder