Skip to content

Commit

Permalink
Add TIL
Browse files Browse the repository at this point in the history
  • Loading branch information
ivelasq committed Feb 18, 2025
1 parent 45d699d commit b92f8a6
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _freeze/til-r/asciicast/index/execute-results/html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"hash": "dffbc2f3ac6dbb7fa66abbc7bbb18bb1",
"result": {
"engine": "knitr",
"markdown": "---\ntitle: \"How to create a GIF of code and its output\"\ndate: '2022-05-10'\ncategory: Other\n---\n\n\n\n\n\nWe can create a GIF of code and its output using [asciicast](https://github.com/r-lib/asciicast). \n\nInstall the development version:\n\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\nremotes::install_github('r-lib/asciicast', ref = remotes::github_pull(24)) \n```\n:::\n\n\n\n\n\nCreate a file called `nzchar.R` with specifications for the GIF and the code to run.\n\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n#' Title: Using nzchar\n#' Columns: 60\n#' Rows: 18\n\n# This is not empty\nSys.getenv(\"R_LIBS_USER\")\n\n# This is empty\nSys.getenv(\"test\")\n\n# This returns TRUE\nnzchar(Sys.getenv(\"R_LIBS_USER\"))\n\n# This returns FALSE\nnzchar(Sys.getenv(\"test\"))\n```\n:::\n\n\n\n\n\nCreate another file that creates the GIF:\n\n\n\n\n\n::: {.cell}\n\n```{.r .cell-code}\n#' Title: Using nzchar\n\nsrc <- \"nzchar.R\"\ncast <- asciicast::record(src)\n\n# <<\n# `cast` is an `asciicast` object, which has some metadata and the\n# recording itself:\n# <<\n\ncast\n\n# <<\n# You can write `cast` to a GIF file with the version installed above.\n# <<\n\nsvg <- tempfile(fileext = \"gif\")\nasciicast::write_gif(cast, svg, theme = \"monokai\")\n```\n:::\n\n\n\n\n\nReally fun for adding to tweets!\n\n![](example.gif){fig-alt=\"An animation created with asciicast that shows that nzchar() returns TRUE when a string is nonempty and FALSE when a string is empty, using Sys.getenv() to query existing 'R_LIBS_USER' and nonexisting 'test' environment variables.\"}\n",
"supporting": [],
"filters": [
"rmarkdown/pagebreak.lua"
],
"includes": {},
"engineDependencies": {},
"preserve": {},
"postProcess": true
}
}
Binary file added images/Screenshot 2025-02-18 at 3.24.41 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Screenshot 2025-02-18 at 3.25.06 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Screenshot 2025-02-18 at 3.30.52 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Screenshot 2025-02-18 at 3.34.26 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
Binary file added til-other/quarto-github-codespaces/images/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added til-other/quarto-github-codespaces/images/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added til-other/quarto-github-codespaces/images/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added til-other/quarto-github-codespaces/images/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added til-other/quarto-github-codespaces/images/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions til-other/quarto-github-codespaces/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: "How to open a Quarto project in GitHub Codespaces"
date: '2025-02-18'
category: Other
output: html_document
---

I recently received a question on [YouTube](https://www.youtube.com/watch?v=uLGe9zuuNl0) about running a Quarto project in GitHub Codespaces. This was new to me, so I did some research (thanks to [Mickaël Canouil](https://github.com/mcanouil) and others for their help!). The key takeaway is that everything needs to be containerized: Quarto, Jupyter, the Quarto extension, R, Python, etc. Simply installing the VS Code Quarto extension is not enough. The easiest way to achieve this is by using the [quarto-codespaces](https://github.com/mcanouil/quarto-codespaces) repository.

1. Fork Mickaël's `quarto-codespaces` repo: <https://github.com/mcanouil/quarto-codespaces>
2. Click the green "Code" button, select "Codespaces," and then "Create codespace on main."

![](images/1.png)

3. Click "Authorize" and continue. Creating the codespace may take a few minutes.

![](images/2.png)

4. Once the codespace is ready, clone your Quarto project into it. For example, to clone the `water-insecurity-dashboard` project, run the following in the terminal:

```bash
git clone https://github.com/ivelasq/water-insecurity-dashboard.git
```

5. Navigate to the project directory: `cd water-insecurity-dashboard`

6. Create a new Python environment. In the Command Palette (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd> or <kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>), select "Python: Create Environment...". Choose "Venv" and the appropriate Python interpreter. **Very importantly,** make sure you check the box to install dependencies from `requirements.txt`.

![](images/3.png)

7. Open your `.qmd` file (e.g., `final.qmd`) and click the "Preview" button in the top right.

![](images/4.png)

That's it! Your Quarto project should now be running in GitHub Codespaces.

![](images/5.png)
File renamed without changes
File renamed without changes.

0 comments on commit b92f8a6

Please sign in to comment.