tl;dr
I wrote a teeny-weeny R Shiny app to serve me a flag challenge whenever I open a new browser tab.
A vexatious request
I thought it would be fun to set my browser tabs to open with thiscatdoesnotexist.com, which serves a random ersatz ‘cat’ as hallucinated by StyleGAN.1 It’s kind of terrifying and time for a change.
We probably accumulate hours of time looking at fresh browser tabs, so why not exploit that for fun and learning? I wanted something visual, quick and low stakes, so… world flags?
My needs were simple: show a mystery flag; reveal who it belongs to; refresh.2 So I built a little {shiny} app, put it in a GitHub repo and served it.
On the front-end you’re presented one of over 250 (!) emoji flags3 at random. There’s a button to reveal the country it represents and another button to refresh the page via {shinyjs}. The back-end just samples a flag from the {emo} package and waits for you to hit refresh. The {bslib} package made it easy to generate a theme that keeps focus on the flag.
So now I’ve set my new tabs to open at https://mattdray.shinyapps.io/randoflag/ (tested on Firefox, Chrome and Safari on iOS 14) and I know what the Guadeloupe flag looks like now.
Hoisting the app
The app is currently hosted online via shinyapps.io and I’ve embedded it below. It’s highly likely I’ll take it down at some point.
Regardless, you can install and run the app from your R session:
shiny::runGitHub("randoflag", "matt-dray", "main")
You’ll need {shiny}, {bslib} and {shinyjs} installed from CRAN and you can get {emo} using remotes::install_github("hadley/emo")
.
Half-mastery
Beware: some emoji flags are shared by more than one geographic entity…
Session info
## ─ Session info ───────────────────────────────────────────────────────────────
## setting value
## version R version 4.0.2 (2020-06-22)
## os macOS 10.16
## system x86_64, darwin17.0
## ui X11
## language (EN)
## collate en_GB.UTF-8
## ctype en_GB.UTF-8
## tz Europe/London
## date 2021-03-03
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
## blogdown 0.21 2020-10-11 [1] CRAN (R 4.0.2)
## bookdown 0.21 2020-10-13 [1] CRAN (R 4.0.2)
## cli 2.3.0 2021-01-31 [1] CRAN (R 4.0.2)
## digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.2)
## evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
## glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
## htmltools 0.5.1.9000 2021-01-17 [1] Github (rstudio/htmltools@11cfbf3)
## knitr 1.31 2021-01-27 [1] CRAN (R 4.0.2)
## magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.2)
## rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.2)
## rmarkdown 2.6 2020-12-14 [1] CRAN (R 4.0.2)
## sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
## stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
## stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
## withr 2.4.1 2021-01-26 [1] CRAN (R 4.0.2)
## xfun 0.21 2021-02-10 [1] CRAN (R 4.0.2)
## yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
##
## [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library