Skip to content

Commit

Permalink
April 2024 post, Closes #73 (#75)
Browse files Browse the repository at this point in the history
* april post init

* update april post

* build future and drafts

* add renv profiles

* renv profile packs

* add readme workflow

* add readme figs

* add readme figs

* move child doc

* Apply suggestions from @maelle

Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>

* update post

* update post

* small grammar

* better readme aux

* updage workflow name

* run readme weekly

---------

Co-authored-by: Maëlle Salmon <maelle.salmon@yahoo.se>
  • Loading branch information
drmowinckels and maelle committed Apr 1, 2024
1 parent b870e20 commit 8073a4a
Show file tree
Hide file tree
Showing 20 changed files with 3,659 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .Rprofile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# source("renv/activate.R")
source("renv/activate.R")
# in .Rprofile of the website project
if (file.exists("~/.Rprofile")) {
base::sys.source("~/.Rprofile", envir = environment())
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/build-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches:
- main

name: Build site
name: Update website

jobs:
build:
Expand Down Expand Up @@ -44,7 +44,10 @@ jobs:
if [[ '${{github.ref}}' == 'refs/heads/main' ]]; then
hugo -e production
else
hugo -b https://${{ github.head_ref }}--drmowinckels.netlify.app/
hugo \
--buildDrafts \
--buildFuture \
-b https://${{ github.head_ref }}--drmowinckels.netlify.app/
fi
- name: Deploy production 🚀
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/render-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * WED'

name: render-rmarkdown

jobs:
render-rmarkdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PROFILE: readme
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v1
- uses: r-lib/actions/setup-renv@v2
- name: Render README
run: Rscript -e 'rmarkdown::render("README.Rmd", "github_document")'
- name: Commit results
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git commit README.md README_files/ \
-m 'Re-build README.Rmd' || echo "No changes to commit"
git push origin || echo "No changes to commit"
10 changes: 9 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.0
Imports:
blogdown,
blogdown
Config/renv/profiles/readme/dependencies:
knitr,
rmarkdown
Config/renv/profiles/aboutme/dependencies:
ggplot2,
knitr,
rmarkdown,
dplyr,
ggplot2,
glue,
Expand All @@ -20,3 +27,4 @@ Imports:
stringr,
tidyr,
vitae

Binary file added README-files/plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 124 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
---
output: github_document
---

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-files/",
fig.retina = 3,
out.width = "100%"
)
```

<center>
![](assets/img/logo.png){width=50%}
</center>

# DrMowinckels website repo!

Welcome to the repository for my website.
This repository contains the code for my content.


```{r, echo = FALSE}
posts <- list.files("content/blog",
"^index.md",
recursive = TRUE,
full.names = TRUE)
posts <- lapply(posts, readLines)
find_key <- function(x, key){
j <- lapply(x, function(x){
k <- grep(sprintf("^%s:", key),
x, value = TRUE)
k <- gsub(sprintf("^%s: |'", key), "", k)
k[1]
})
unlist(j)
}
postdf <- data.frame(
n = seq_along(posts),
draft = find_key(posts, "draft") |>
grepl(pattern = "true", x = _),
date = as.Date(find_key(posts, "date")),
slug = find_key(posts, "slug") |>
gsub('\\"', "", x = _),
title = find_key(posts, "title")
) |>
subset(subset = !draft)
postdf$link <- sprintf("[%s](https://drmowinckels.io/blog/%s)",
postdf$title,
postdf$slug)
today <- Sys.Date()
min_date <- min(postdf$date)
last_post <- as.numeric(max(postdf$date) - today)
postavg <- nrow(postdf)/as.numeric(today - min_date) * 30
postavg <- sprintf("%0.2f", postavg)
postbtw <- as.numeric(today - min_date) / nrow(postdf)
postbtw <- sprintf("%s", round(postbtw, digits = 0))
```

## Some stats

🎉 DrMowinckels has **`r nrow(postdf)`** posts since **`r min_date`**!

📅 That's a post roughly every **`r postbtw`** days, or about **`r postavg`** posts per month, since `r min_date`.


✍️ The last post was published **`r last_post`** days ago (`r tail(postdf, 1)$link`).

😉 I'll post as often as I am able, and hope people find it interesting. I'd love your feedback in the comments!


```{r 'plot', echo = FALSE, fig.width=10, fig.height=2.5}
library(lattice)
postdf$ones <- 1
# Assuming postdf is loaded and has a 'date' column
xyplot(ones ~ date, data = postdf,
type = 'p',
pch = "|",
cex = 5,
col = "cyan3",
xlab = "",
ylab = "",
main = "Published posts",
scales = list(x = list(cex = 1.4), y = list(draw = FALSE)),
strip = FALSE, # Removes strip labels
axis.line = list(col = "transparent"),
layout = c(1, 1), # Single panel
par.settings = list(
strip.border = list(col = "transparent"), #making the border transparent
axis.line = list(col = "transparent") #making the axes transparent
)
)
```

<details><summary>📂 Click to expand a full list of posts</summary>

```{r posts-table, results='asis', echo = FALSE}
data.frame(
Date = rev(postdf$date),
Title = rev(postdf$link)
) |>
knitr::kable()
```
</details>

---

_The automatically rendered readme was inspired by [Matt Dray](https://www.rostrum.blog/2021/04/14/gha-readme/) and [Piping Hot Data](https://github.com/shannonpileggi/pipinghotdata_distill/blob/master/README.Rmd)._


_Updated `r Sys.time()`_
82 changes: 68 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,74 @@
### Hi there 👋

- Pronouns: She/Her
- How to reach me:
- mastodon: [@DrMowinckels@fosstodon.org](https://fosstodon.org/web/@Drmowinckels)
- website: [DrMowinckels](https://drmowinckels.io/)
<!-- README.md is generated from README.Rmd. Please edit that file -->
<center>
<img src="assets/img/logo.png" style="width:50.0%" />
</center>

I'm part of the [R-Ladies](https://rladies.org/) global team, where I particularly focus on the website development and maintenance, as well as the YouTube channel.
I am a Certified [Sorftware Carpentry](https://software-carpentry.org/) Instructor, where I am able to teach git, bash and R lessons, and a Certified [Posit Tidyverse instructor](https://education.rstudio.com/trainers/people/mowinckel+athanasia/).
# DrMowinckels website repo!

I work as a staff scientist at [the Center for Lifespan Changes in Brain and Cognition](www.oslobrains.no) at the University of Oslo.
Welcome to the repository for my website. This repository contains the
code for my content.

- 🌱 I’m currently learning
- javascript
- make

## Some stats

This repository contains the source code for my website [drmowinckels.io/](https://drmowinckels.io/).
🎉 DrMowinckels has **31** posts since **2018-03-08**!

[![Netlify Status](https://api.netlify.com/api/v1/badges/50e45b32-809c-429b-8fa9-16fd1fb67ee3/deploy-status)](https://app.netlify.com/sites/drmowinckels/deploys)
📅 That’s a post roughly every **71** days, or about **0.42** posts per
month, since 2018-03-08.

✍️ The last post was published **5** days ago ([Too much git
cleaning](https://drmowinckels.io/blog/2024/git-clean-woes)).

😉 I’ll post as often as I am able, and hope people find it interesting.
I’d love your feedback in the comments!

<img src="README-files/plot-1.png" width="100%" />

<details>
<summary>
📂 Click to expand a full list of posts
</summary>

| Date | Title |
|:-----------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 2024-04-01 | [Too much git cleaning](https://drmowinckels.io/blog/2024/git-clean-woes) |
| 2024-03-01 | [Setting up a Freesurfer LMM through R](https://drmowinckels.io/blog/freesurfer-lmm-r) |
| 2024-02-01 | [Teaching you - teaching me](https://drmowinckels.io/blog/teaching-unlocks) |
| 2024-01-01 | [New year, New blog](https://drmowinckels.io/blog/newyear-newblog) |
| 2023-11-03 | [Reorganising Hugo Content and Aliasing](https://drmowinckels.io/blog/reorganising-hugo) |
| 2023-09-26 | [Posit::conf 2023](https://drmowinckels.io/blog/positconf-2023) |
| 2022-12-01 | [Advent of R Functions](https://drmowinckels.io/blog/advent-of-r-functions) |
| 2022-11-07 | [Lets Get Applying](https://drmowinckels.io/blog/lets-get-applying) |
| 2021-12-17 | [Rmarkdown Child Templates](https://drmowinckels.io/blog/rmarkdown-child-templates) |
| 2021-12-04 | [Adding giscus to your blogdown site](https://drmowinckels.io/blog/adding-giscus-to-your-blogdown-site) |
| 2021-03-23 | [Using GitHub Actions to Build your Hugo Website](https://drmowinckels.io/blog/using-github-actions-to-build-your-hugo-website) |
| 2021-03-14 | [New {ggseg} with Geom!](https://drmowinckels.io/blog/new-ggseg-with-geom) |
| 2020-12-31 | [New Years Wishes](https://drmowinckels.io/blog/new-year-s-wishes) |
| 2020-12-25 | [R-Package Advent Calendar 2020](https://drmowinckels.io/blog/r-package-advent-calendar) |
| 2020-06-24 | [The Linear Regression Family in R](https://drmowinckels.io/blog/the-linear-regression-family-in-r) |
| 2020-05-25 | [Changing your Blogdown Workflow](https://drmowinckels.io/blog/changing-you-blogdown-workflow) |
| 2020-04-30 | [Using Freesurfer annotation files to plot in R](https://drmowinckels.io/blog/using-freesurfer-annotation-files-to-plot-in-r) |
| 2019-12-11 | [Do you wanna build a snowman?](https://drmowinckels.io/blog/do-you-wanna-build-a-snowman) |
| 2019-12-06 | [ggseg3d - creating interactive brain segmentation plots with plotly](https://drmowinckels.io/blog/ggseg3d-creating-interactive-brain-segmentation-plots-with-plotly) |
| 2019-11-16 | [Plotting GAMM interactions with ggplot2](https://drmowinckels.io/blog/plotting-gamm-interactions-with-ggplot2) |
| 2019-07-17 | [“R for Psychologists - part II”](https://drmowinckels.io/blog/r-for-psychologists-part-ii) |
| 2019-02-02 | [Building tidy tools - a quick recap of RStudio::conf 2019 workshop & teeny demonstration](https://drmowinckels.io/blog/building-tidy-tools-a-quick-recap-of-rstudio-conf-2019-workshop) |
| 2019-01-19 | [Why RStudio::conf is the best conference experience I have had](https://drmowinckels.io/blog/why-rstudio-conf-is-the-best-conference-experience-i-have-had) |
| 2018-12-13 | [Christmas tree in ggplot](https://drmowinckels.io/blog/christmas-tree-in-ggplot) |
| 2018-11-09 | [R for psychologists - just dive into it!](https://drmowinckels.io/blog/r-just-dive-into-it) |
| 2018-10-01 | [Get the brain animated!](https://drmowinckels.io/blog/get-the-brain-animated) |
| 2018-08-30 | [Introducing the ggseg R-package for brain segmentations](https://drmowinckels.io/blog/introducing-the-ggseg-r-package-for-brain-segmentations) |
| 2018-05-25 | [Circular plots in R and adding images](https://drmowinckels.io/blog/circluar-plots-in-r-and-adding-images) |
| 2018-05-07 | [Adding external images to plots](https://drmowinckels.io/blog/adding-external-images-to-plots) |
| 2018-04-05 | [GAMM random effects](https://drmowinckels.io/blog/gamm-random-effects) |
| 2018-03-08 | [GAMM spaghetti plots in R with ggplot](https://drmowinckels.io/blog/gamm-spaghetti-plots-in-r-with-ggplot) |

</details>

------------------------------------------------------------------------

*The automatically rendered readme was inspired by [Matt
Dray](https://www.rostrum.blog/2021/04/14/gha-readme/) and [Piping Hot
Data](https://github.com/shannonpileggi/pipinghotdata_distill/blob/master/README.Rmd).*

*Updated 2024-03-27 00:57:01.937857*
2 changes: 1 addition & 1 deletion content/blog/2021/12-17-rmarkdown-child-templates/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,4 @@ Now, we can copy and paste that code chunk for all three species, and have a nea
You can have a look at the documents in the github repo of this post, and hopefully it will make some sense.

- [Main document](https://github.com/Athanasiamo/DrMowinckels/tree/master/content/blog/2021-12-17-rmarkdown-child-templates/main-document.Rmd)
- [Child document](https://github.com/Athanasiamo/DrMowinckels/tree/master/content/blog/2021-12-17-rmarkdown-child-templates/species-child.Rmd)
- [Child document](https://github.com/Athanasiamo/DrMowinckels/tree/master/static/blog/2021-12-17-rmarkdown-child-templates/species-child.Rmd)

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions content/blog/2024/04-01_git_clean/index.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: Too much git cleaning
author: Dr. Mowinckel
date: '2024-04-01'
image: 'confused-kitten.png'
tags:
- git
- fail
- rstudio
- r
slug: "2024/git-clean-woes"
summary: |
Version control is great, but sometimes it can trip you up!
In this post I recount my rather stupid mistake of using `git clean` when I shouldn't have,
and how I got out of it.
---

```{r, include=FALSE}
options(max.print = 40)
```

I have a type of love-hate relationship with git.
While I love the idea of version control, I often find myself in a situation where I have to clean up my git history.
Maybe I have committed a file that I shouldn't have, or I have made a mistake in my commit message, or I went down a path that just didn't work out.
In these cases, I find myself using `git clean` or `git checkout` quite a bit.
In the worst case, I'll even do a `git reset --hard` to go back to a previous commit.
What all these do, is enable me to go back in time and start over.
`reset` will let you go back in time even after committing, and deciding that the commit is not what you wanted.
The other two help more if you haven't committed yet, but have made changes that you want to get rid of.

I have found that the more I use these commands, the more I get used to them.
But that doesn't mean that I actually do them correctly.
I have had my fair share of mistakes, where I have lost work that I didn't want to lose.
I had one when preparing my [previous post](/blog/2024/freesurfer-lmm-r/)!

I was working on the {neuromat} package, and I had made some changes to the code that just wasn't what i was after.
I decided I wanted to ditch the changes, and go back to what I had before.

`git clean -f`

`git clean -f` removes any untracked files, poof, gone are they.
And one of the main things I had done was rename and create new files and re-arrange my code.
So, that quickly deleted all of that work.
Which I kind of wanted, it just went further back in time than I expected.

To my horror... I had forgotten to commit the changes I wanted to keep.
The majority of the good things I had done, went away with the stuff I didn't like.
I felt... defeated.

I had to start over, and redo the work I had done.
[Maëlle Salmon](https://masalmon.eu/) to the rescue!
I had a chat with her, mostly ranting about how stupid I was, and she suggested I could try to just "undo" in any of my open documents.
In this instance, I was using RStudio IDE, which is my go-to IDE for R work, especially R package dev work (lookout for a future post on my IDE preferences).
"Undo" here meant hitting `ctrl`+ `z`.
In my fury over my git mistakes, I forgot that such a simple solution could exist!

Presto, I could just "undo" myself back to the state I wanted to be in.
Ok, so I did lose some things that I had done, but they were rather small and easy to fix.

Both for the mistake, and not thinking of the fairly simple solution.

Thankfully, other more experienced and advanced developers than me also make such mistakes.

{{< toot user="Patricia" server="social.vivaldi.net" toot="112094753393319808" >}}

It's always nice to know that you're not alone in your mistakes.

And trust that the awesome [Julia Evans](https://fosstodon.org/@b0rk@jvns.ca) of course has [a zine](https://wizardzines.com/comics/losing-your-work/) for this!
And if she has a zine for it, I know I'm in good company.

And if you, like me (and so many others), need help on your git journey, Maëlle also has an amazing R package to help you practice!
Read her [Instroduction to {saperlipopette}](https://masalmon.eu/2024/01/18/saperlipopette-package-practice-git/) to get started!
Loading

0 comments on commit 8073a4a

Please sign in to comment.