In the middle of the desert you can say anything you want
I missed an ability to recursively look for elements matching a condition in panflute, so:
def _recursively_find_elements(
element: Element | list[Element], condition: Callable
) -> list[Element]:
"""Return panflute element(s) and their descendants that match conditition.
"""
results = list()
def action(el, doc):
if condition(el):
results.append(el)
if not isinstance(element, list):
element = [element]
for e in element:
e.walk(action)
return results
# sample condition
def is_header(e) -> bool:
cond = e.tag == "Header" and e.level == 2 # and "data-pos" in e.attributes
return cond
Ah, to read:
ddoc = pf.convert_text(
markdown,
input_format="commonmark_x+raw_html+bracketed_spans+fenced_divs+sourcepos",
output_format="panflute",
)
To output readably:
pf.stringify(el).strip()
input_format
has to be commonmark[_x]+
sourcepos
sourcepos
isn’t too well documented, only w/ commonmark
el.attributes['data-pos']
a la 126:1-127:1
line_no
always matching what I expectdef _parse_data_pos(p: str) -> tuple[tuple[int, int], tuple[int, int]]:
"""Parse data-pos string to (line, char) for start and end.
Example: '126:1-127:1' -> ((126, 1), (127, 1))
Arguments:
p: data-pos string as generated by commonmark+sourcepos extension.
"""
start, end = p.split("-")
start_l, start_c = start.split(":")
end_l, end_ch = end.split(":")
return (int(start_l), int(start_c)), (int(end_l), int(end_ch))
Fish Shell function for sourcing standard .env files :
. (sed 's/^/export /' .env | psub)
(And yet another mention of Taskfile that I’ll definitely look into nowG)
I want to automatically get the PDF version of quarto/reveal presentations.
The usual way would be to open the presentation in export mode e
, then print with no margins through the usual print window.
I want to do this automatically as part of a CI/CD pipeliene.
selenium-print · PyPI / bubblegumsoldier/selenium-print uses selenium+chromium to do this.
As for the printing options available in Chrome, this looks relevant:
selenium-print/seleniumprint/drivers/chrome_pdf_driver.py at main · bubblegumsoldier/selenium-print
pdf = self.driver.execute_cdp_cmd("Page.printToPDF", {"printBackground": True})
OK, so it’s all a static option.
Chrome DevTools Protocol - Page domain has the other available options — which is what I need.
The rest of the code feels like a wrapper to this — maybe I can drop the entire library and just use these single bits?
TL;DR use your own personal settings, then “dev settings” (!), then create one but set the resource owner to the organization.
(As of 2024-10-14. Hard to find clear AND CORRECT documentation on this.)
Create access token for organization · community · Discussion #74701.
string collect
: string-collect - join strings into one — fish-shell 3.7.1 documentationset VARNAME (cat ~/myfile | string collect)
Here string collect
makes sure it’s a multiline variable instead of an array composed of one element per line.
Gitlab mirroring didn’t work for me after trying for hours, I give up. CI/CD it is.
On a slow connection or other constraints, you can check out only the last N commits or only a specific branch:
git clone --depth 3 --branch some-branch https://some-repo.org
TIL1:
./git/info/exclude
is your local .gitignore
outside the repository tree!git update-index --assume-unchanged .gitignore
makes git stop checking the changes for that file in the working tree. --no-assume-unchanged
to take it back.23Finally a place for my local ignores that won’t appear in autocomplete suggestions for git add
and friends. In Pycharm I have changelists, and now I finally have a solution for my just-as-usual vim/git/CLI workflow as well.
BUT:
exclude
won’t work if the file is already tracked (says SO but for me it works?..)As of 2024-10-02 20:16 at least.
give me the ag command to look inside markdown and yaml files only
GPT4o1:
`ag --include='*.md' --include='*.yaml' --include='*.yml' 'search_pattern'`
GPT42:
`ag "search_pattern" --markdown --yaml`