Skip to content

Commit

Permalink
Correct typo, add footnote to perpetual-restart post; rebuild site
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-dray committed Apr 3, 2024
1 parent 3ab0c18 commit aa5f548
Show file tree
Hide file tree
Showing 172 changed files with 2,225 additions and 376 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"hash": "1d449ea3529883ff112cfc894dea954f",
"hash": "bb8af46925aed2f683ce7d498f6077ed",
"result": {
"markdown": "---\ntitle: \"Stop Jenny committing arson\"\ndate: 2024-04-01\nslug: \"perpetual-restart\"\nimage: resources/arson.png\ncategories:\n - r\n - reproducibility\n---\n\n\n![This image has been edited. With apologies.](resources/arson.png){fig.alt=\"Posit employee Jenny Bryan on stage at a lectern. Her eyes are emoji flames. In red Comic Sans around her are the words 'fire', 'computer' and 'burn', as well as the R code 'rm(list=ls())'. There is a flame effect along the bottom of the image.\" width='100%'}\n\n## tl;dr\n\nMake RStudio restart itself. Perpetually.\n\n<div class=\"tip\"> \n`<svg aria-hidden=\"true\" role=\"img\" viewBox=\"0 0 512 512\" style=\"height:1em;width:1em;vertical-align:-0.125em;margin-left:auto;margin-right:auto;font-size:inherit;fill:currentColor;overflow:visible;position:relative;\"><path d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\"/></svg>`{=html} <b>Note</b>\n\nThis post contains April Fool's Day content.\n\n</div>\n\n## Passing the torch\n\n[Jenny Bryan once said](https://www.tidyverse.org/blog/2017/12/workflow-vs-script/):\n\n> If the first line of your R script is `rm(list = ls())` I will come into your office and SET YOUR COMPUTER ON FIRE 🔥.\n\nThe objects in your R environment are wicked little imps whose only motivation is to deceive you. They must be destroyed. Frequently. \n\nBut `rm(list = ls())` isn't enough to start a new session with a completely a clean slate. It doesn't detach packages, for example. Reproducibility is at stake here, folks!\n\nThe only salvation is to completely restart R. All the time.\n\nI don't think you heard me. Come closer. I said _all the time_.\n\n## An extinguisher\n\nI've been [woke to this thought technology](https://www.rostrum.blog/posts/2020-04-17-r-self-shame/index.html#env) for a while. You're right, it's time I gave back to the community.\n\nI can't trust you to restart R voluntarily, so I must help you to help yourself.\n\nSo, I have for you a gift. A precious snippet of R code that came to me in a fever dream.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsetHook(\n \"rstudio.sessionInit\",\n function(...) {\n message(\"⏳ You have 30 seconds...\")\n Sys.sleep(30)\n rstudioapi::executeCommand(\"restartR\")\n }\n)\n```\n:::\n\n\nSimply open your `.Rprofile`[^dont1] ([a special file](https://support.posit.co/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf) that's executed at start up) with `usethis::edit_r_profile()`[^dont2], paste in the code[^dont3] and then restart R for it to take effect[^dont4].\n\nWhat does it do? It waits 30 seconds after RStudio starts up[^thespicemelange] and then restarts R[^restart].\n\n...Which prompts another restart after 30 more seconds.\n\n...And another.\n\n...Forever[^quit].\n\n![trapped in a loop help I'm](resources/restart.png){fig.alt=\"The R console in RStudio. Repeated several times is the message 'restarting in 30 seconds...' then 'restarting R session'.\" width='100%'}\n\nI know what you're thinking: doesn't this block the console? Kind of. You can still type stuff and it'll be executed before the next restart. Only to disappear immediately. \n\nComplete panic. Just like Jenny wanted! I think?\n\n## Rise from the ashes\n\nHow can you thank me for this? I am humble (extremely), but you're welcome to [support my Patreon](https://github.com/scrogster/rickrollR/).\n\nHappy March 32nd, colleagues.\n\n### Environment {.appendix}\n\n<details><summary>Session info</summary>\n\n::: {.cell}\n::: {.cell-output .cell-output-stdout}\n```\nLast rendered: 2024-04-01 08:48:55 BST\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\nR version 4.3.1 (2023-06-16)\nPlatform: aarch64-apple-darwin20 (64-bit)\nRunning under: macOS Ventura 13.2.1\n\nMatrix products: default\nBLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib \nLAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0\n\nlocale:\n[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8\n\ntime zone: Europe/London\ntzcode source: internal\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nloaded via a namespace (and not attached):\n [1] htmlwidgets_1.6.2 compiler_4.3.1 fastmap_1.1.1 cli_3.6.2 \n [5] tools_4.3.1 htmltools_0.5.8 rstudioapi_0.16.0 yaml_2.3.8 \n [9] rmarkdown_2.26 knitr_1.45 jsonlite_1.8.8 xfun_0.43 \n[13] digest_0.6.35 rlang_1.1.3 fontawesome_0.5.2 evaluate_0.23 \n```\n:::\n:::\n\n</details>\n\n[^dont1]: Don't.\n[^dont2]: Don't.\n[^dont3]: Don't.\n[^dont4]: Fine, [dew it](https://www.youtube.com/watch?v=lCscYsICvoA).\n[^quit]: Maybe you'll have to force quit RStudio? Use <kbd>Cmd</kbd>+<kbd>Option</kbd>+<kbd>Esc</kbd> on a Macintosh or <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Delete</kbd> on Michaelsoft Binbows. I assume Linux users know what they're doing.\n[^thespicemelange]: If you're feeling extra spicy, maybe randomise the wait period!\n[^restart]: I also tried `rsudioapi::restartSession()` and `.rs.restartR()` here, but they didn't work quite as I expected. Let me know any non-RStudio ways to do this, of course.",
"markdown": "---\ntitle: \"Stop Jenny committing arson\"\ndate: 2024-04-01\nslug: \"perpetual-restart\"\nimage: resources/arson.png\ncategories:\n - r\n - reproducibility\n---\n\n\n![This image has been edited. With apologies.](resources/arson.png){fig.alt=\"Posit employee Jenny Bryan on stage at a lectern. Her eyes are emoji flames. In red Comic Sans around her are the words 'fire', 'computer' and 'burn', as well as the R code 'rm(list=ls())'. There is a flame effect along the bottom of the image.\" width='100%'}\n\n## tl;dr\n\nMake RStudio restart itself. Perpetually.\n\n<div class=\"tip\"> \n`<svg aria-hidden=\"true\" role=\"img\" viewBox=\"0 0 512 512\" style=\"height:1em;width:1em;vertical-align:-0.125em;margin-left:auto;margin-right:auto;font-size:inherit;fill:currentColor;overflow:visible;position:relative;\"><path d=\"M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24V264c0 13.3-10.7 24-24 24s-24-10.7-24-24V152c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\"/></svg>`{=html} <b>Note</b>\n\nThis post contains April Fools' Day content.\n\n</div>\n\n## Passing the torch\n\n[Jenny Bryan once said](https://www.tidyverse.org/blog/2017/12/workflow-vs-script/):\n\n> If the first line of your R script is `rm(list = ls())` I will come into your office and SET YOUR COMPUTER ON FIRE 🔥.\n\nThe objects in your R environment are wicked little imps whose only motivation is to deceive you. They must be destroyed. Frequently. \n\nBut `rm(list = ls())` isn't enough to start a new session with a completely clean slate. It doesn't detach packages, for example. Reproducibility is at stake here, folks!\n\nThe only salvation is to completely restart R. All the time.\n\nI don't think you heard me. Come closer. I said _all the time_.\n\n## An extinguisher\n\nI've been [woke to this thought technology](https://www.rostrum.blog/posts/2020-04-17-r-self-shame/index.html#env) for a while. You're right, it's time I gave back to the community.\n\nI can't trust you to restart R voluntarily, so I must help you to help yourself.\n\nSo, I have for you a gift. A precious snippet of R code that came to me in a fever dream.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsetHook(\n \"rstudio.sessionInit\",\n function(...) {\n message(\"⏳ Restarting in 30 seconds...\")\n Sys.sleep(30)\n rstudioapi::executeCommand(\"restartR\")\n }\n)\n```\n:::\n\n\nSimply open your `.Rprofile`[^dont1] ([a special file](https://support.posit.co/hc/en-us/articles/360047157094-Managing-R-with-Rprofile-Renviron-Rprofile-site-Renviron-site-rsession-conf-and-repos-conf) that's executed at start up) with `usethis::edit_r_profile()`[^dont2], paste in the code[^dont3] and then restart R for it to take effect[^dont4].\n\nWhat does it do? It waits for RStudio to start up[^rstudio] and then restarts R[^restart] after 30 seconds[^thespicemelange].\n\n...Which prompts another restart after 30 more seconds.\n\n...And another.\n\n...Forever[^quit].\n\n![trapped in a loop help I'm](resources/restart.png){fig.alt=\"The R console in RStudio. Repeated several times is the message 'restarting in 30 seconds...' then 'restarting R session'.\" width='100%'}\n\nI know what you're thinking: doesn't this block the console? Kind of. You can still type stuff and it'll be executed before the next restart. Only to disappear immediately. \n\nComplete panic. Just like Jenny wanted! I think?\n\n## Rise from the ashes\n\nHow can you thank me for this? I am humble (extremely), but you're welcome to [support my Patreon](https://github.com/scrogster/rickrollR/).\n\nHappy March 32nd, colleagues.\n\n### Environment {.appendix}\n\n<details><summary>Session info</summary>\n\n::: {.cell}\n::: {.cell-output .cell-output-stdout}\n```\nLast rendered: 2024-04-03 08:14:51 BST\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\nR version 4.3.1 (2023-06-16)\nPlatform: aarch64-apple-darwin20 (64-bit)\nRunning under: macOS Ventura 13.2.1\n\nMatrix products: default\nBLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib \nLAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0\n\nlocale:\n[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8\n\ntime zone: Europe/London\ntzcode source: internal\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nloaded via a namespace (and not attached):\n [1] htmlwidgets_1.6.2 compiler_4.3.1 fastmap_1.1.1 cli_3.6.2 \n [5] tools_4.3.1 htmltools_0.5.8 rstudioapi_0.16.0 yaml_2.3.8 \n [9] rmarkdown_2.26 knitr_1.45 jsonlite_1.8.8 xfun_0.43 \n[13] digest_0.6.35 rlang_1.1.3 fontawesome_0.5.2 evaluate_0.23 \n```\n:::\n:::\n\n</details>\n\n[^dont1]: Don't.\n[^dont2]: Don't.\n[^dont3]: Don't.\n[^dont4]: Fine, [dew it](https://www.youtube.com/watch?v=lCscYsICvoA).\n[^quit]: Maybe you'll have to force quit RStudio? Use <kbd>Cmd</kbd>+<kbd>Option</kbd>+<kbd>Esc</kbd> on a Macintosh or <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Delete</kbd> on Michaelsoft Binbows. I assume Linux users know what they're doing.\n[^thespicemelange]: If you're feeling extra spicy, maybe randomise the wait period!\n[^restart]: I also tried `rsudioapi::restartSession()` and `.rs.restartR()` here, but they didn't work quite as I expected. Let me know any non-RStudio ways to do this, of course.\n[^rstudio]: The code depends on the {rstudioapi} package, but it needs to load before it can be used. This seems to happen _after_ the .Rprofile has been read. This is why we have to use `setHook()` with `rstudio.sessionInit` so the restart command can be executed once RStudio has initiated.\n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
Expand Down

0 comments on commit aa5f548

Please sign in to comment.