Compare commits

...

2 Commits

Author SHA1 Message Date
Jake Howard d5aee63bd5
Hide TOC on short pages 2024-02-22 18:05:49 +00:00
Jake Howard 9052286c0b
Add note for changing Heroku's release dyno type 2024-02-22 17:27:36 +00:00
4 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,28 @@
---
title: Scaling Heroku's release type
tags:
- Heroku
---
During `release`, it's possible to consume so much memory, Heroku kills the dyno before it finishes executing.
```
heroku[release.xxxx]: Process running mem=1038M(202.8%)
heroku[release.xxxx]: Error R15 (Memory quota vastly exceeded)
heroku[release.xxxx]: Stopping process with SIGKILL
heroku[release.xxxx]: Process exited with status 137
heroku[release.xxxx]: State changed from up to complete
```
When that happens, the release fails (even though it may say "complete"). Whilst it's a good idea not to use huge amounts of memory during release, sometimes it's unavoidable.
Releases run in a `Standard-1X` dyno, regardless of what the other dynos are set to. This has a 512MB RAM limit, however Heroku will let it push over for short periods.
Setting the `release` dyno type can't be done from the dashboard, but can be done from the CLI:
```
heroku ps:type release=Standard-1X -a <app>
```
!!! warning
When running `Eco` or `Basic` dynos, the release container is configured to match. It's not possible to use other types of dyno on these plans.

View File

@ -0,0 +1,13 @@
---
title: Hide short Table of Contents
tags:
- Mkdocs
---
Some of my notes don't have headings. Others have barely any. However, the Table of Contents area takes up a large area of screen for no reason.
This hook only shows the Table of Contents area when there are more than 4 headings (at any level).
```python
{! ../hooks/hide_toc.py !}
```

19
hooks/hide_toc.py Normal file
View File

@ -0,0 +1,19 @@
from mkdocs.structure.toc import TableOfContents
def flatten_toc(item):
yield item
children = item.items if isinstance(item, TableOfContents) else item.children
for subitem in children:
yield from flatten_toc(subitem)
def on_page_content(html, page, config, files):
if not page.url.startswith("notes/") or page.file.src_uri == "notes/index.md":
return
toc = list(flatten_toc(page.toc))
if len(toc) <= 4:
hidden_items = page.meta.setdefault("hide", [])
if "toc" not in hidden_items:
hidden_items.append("toc")

View File

@ -55,6 +55,7 @@ theme:
hooks:
- hooks/notes.py
- hooks/tag_nav.py
- hooks/hide_toc.py
# Extensions
markdown_extensions: