Skip to content

Commit

Permalink
auto add date
Browse files Browse the repository at this point in the history
  • Loading branch information
HDembinski committed May 17, 2024
1 parent 4eca325 commit 0ff9685
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: quarto-dev/quarto-actions/setup@v2
- run:
python auto_add_date.py posts/*.ipynb
quarto render
- uses: actions/upload-pages-artifact@v3
with:
Expand Down
26 changes: 26 additions & 0 deletions auto_add_date.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys
import nbformat
import subprocess as subp

for fn in sys.argv[1:]:
with open(fn) as f:
nb = nbformat.read(f, as_version=4)

r = subp.run(
["git", "log", "--follow", "--format=%ad", "--date=short", fn], stdout=subp.PIPE
)
dates = [x for x in r.stdout.decode().split("\n") if x]
date = dates[-1]

if nb.cells and nb.cells[0].cell_type != "raw":
front_matter = f"""
---
date: {date}
---
"""
print(f"adding frontmatter to {fn}\n{front_matter}")

nb.cells = [nbformat.v4.new_raw_cell(front_matter)] + nb.cells

with open(fn, "w") as f:
nbformat.write(nb, f)
4 changes: 2 additions & 2 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ listing:
sort: "date desc"
type: default
categories: false
sort-ui: false
filter-ui: false
sort-ui: true
filter-ui: true
page-layout: full
title-block-banner: true
---
4 changes: 4 additions & 0 deletions posts/exceptions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
date : 2020-04-05
---

# C++ exceptions in high-performance code

Here is a collection of advice on using exceptions in high-performance libraries. There has been a lot of discussion in the Boost community about exceptions lately, since [some people want to](http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0.pdf) [improve error reporting in C++](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1095r0.pdf), which led to the development of [Boost.Outcome](https://www.boost.org/doc/libs/1_72_0/libs/outcome/doc/html/index.html) and similar libraries. Here we deal with classic C++ exceptions.
Expand Down

0 comments on commit 0ff9685

Please sign in to comment.