In the middle of the desert you can say anything you want
Hugo summaries are weird.
.Summary
returns whatever summary it has, which is either the .. more ..
tag, then everything before it gets returned including formatting, or whatever is set in the settings as summary length, while removing markdown formatting.
There was no easy way to get an auto-summary with preserved formatting, except manually adding stuff.
What I really wanted is to truncate posts manually when needed, and leave the rest in full by default while preserving formatting.
Setting the limit to infinite made .Summary
returned the full post with stripped formatting.
(I needed this for footnotes in multiple posts all on the home page, they got mixed up and there were no clean solutions. The blackfriday
renderer could fix this, but not the default goldmark
, which I’m using for some layout issues it does better.)
After googling for better ways to truncate with preserved formatting, found Summary .Render · Scott Willsey
It has this code for a better summarization:
{{ if gt ( sub (len (plainify .Content)) (len .Summary)) 10 }}
{{ .Content | replaceRE "<sup.+>.+</sup>" "" | safeHTML | truncate (len .Summary) }}
<p><i>(<a href="{{ .RelPermalink }}">Read More</a>)</i></p>
{{ else }}
{{ .Content | safeHTML }}
{{- end -}}
{{- if .Params.linkurl -}}
<p><a href="{{ .RelPermalink }}"><i class="fas fa-level-down-alt fa-xs"></i> Permalink</a></p>
{{- end -}}
First up is an if statement that checks to see if the post even needs to be truncated into a summary or not, or whether it’s short enough to just show the whole post.
this works nice, but I wanted no summarization for
{{ if .Truncated}}
{{ .Summary }}
<p><i>(<a href="{{ .RelPermalink }}">Read More</a>)</i></p>
{{ else }}
{{ .Content | safeHTML }}
{{- end -}}
{{- if .Params.linkurl -}}
<p><a href="{{ .RelPermalink }}"><i class="fas fa-level-down-alt fa-xs"></i> Permalink</a></p>
{{- end -}}
and setting the summary limit to infinite.
What this does is:
.Truncated
, return its summary. This means that the POST IS TRUNCATED ONLY IF I MANUALLY ADD THE MORE TAG, because the auto-summary limit is set to a big number.safeHTML
is prolly not needed there but whatever.When downloading a Google Colab (and prolly a classic Jupyter Notebook) as .py it preserves the plain-text cells as python comments!
From No more disk space: How can I find what is taking up the space? - Ask Ubuntu, run this as root:
du -cha --max-depth=1 | grep -E "M|G"
The grep is to limit the returning lines to those which return with values in the Megabyte or Gigabyte range.
Next one would be /var
etc.
Then there’s ncdu
and friends too.
From SO’s credentials - How can I save username and password in Git? - Stack Overflow:
git config --global credential.helper store
Then on the next git pull
the credentials entered will be saved in plain text on disk.
Wow. WOW.
Wrote a program accepting a LONG --yes_delete_all_data_completely
, without a short version, to make sure no one does an error and deletes everything.
Today I mistyped a --y
parameter, it started in the mode above.
Then I learned that argparse does prefix matching.
python - How to share global variables between tests? - Stack Overflow:
import pytest
def pytest_configure():
pytest.my_symbol = MySymbol()
allows then to use pytest.my_symbol
elsewhere, it’s a part of global pytest namespace now.
That said, fixtures are still the preferred way it seems (todo - how are they shared between files?)
Playing with
Spacy and it’s as nice and I thought it’d be.
Interesting bits and general dump of first impressions:
Doc
and Span
are heavily token-based, including for NER stuff. Can’t set a sub-token entity, for example.Doc.char_span()
supports creating a Span based on characters and various alignment methods! Doc · spaCy API Documentation
Example
class for individual training instances can do neat stuff with BIO mapping, aligning of NER tokens etc: Example · spaCy API DocumentationWhen writing a function requiring a --yes_I_know_what_this_means_delete_everything
and writing a warning message with tens of exclamation points, I decided that ASCII art is the better way to go.
Found this: Caution Text Art (Copy & Paste) - textart.sh
Allows even changing backgrounds from spaces to _
s etc.!
textart.sh has a lot of topics and allows basic customisation of the arts themselves.
(Can’t find a single ASCII art piece with an artists’ signature though, which kinda worries me. And the dynamic scrolling without a way to see a list of all results…)
“pic"related:
░░░░
██
██░░██
░░ ░░ ██░░░░░░██ ░░░░
██░░░░░░░░░░██
██░░░░░░░░░░██
██░░░░░░░░░░░░░░██
██░░░░░░██████░░░░░░██
██░░░░░░██████░░░░░░██
██░░░░░░░░██████░░░░░░░░██
██░░░░░░░░██████░░░░░░░░██
██░░░░░░░░░░██████░░░░░░░░░░██
██░░░░░░░░░░░░██████░░░░░░░░░░░░██
██░░░░░░░░░░░░██████░░░░░░░░░░░░██
██░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░██
░░ ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
██████████████████████████████████████████
░░
Okay, this blew my mind. Taskwarrior can have lowercase +t
tags, along with the +T
-uppercase ones I’ve been using my entire life.
Wow.
Not the first time I’m touching the topic here :) But yet another repo to set up, and realized I didn’t really get “new remote” vs “remote URI”
Details: Managing remote repositories - GitHub Docs
Easy simple take: How to Add a New Remote to your Git Repo | Assembla Help Center
# add
git remote add remote_name_github git@github.com:me/name.git
# show the result ('verify')
git remote -v
# push _specifically to that remote_
git push remote_name_github
Github 1 helps:
git remote set-url --add --push origin git://original/repo.git
git remote set-url --add --push origin git://another/repo.git
… and gives the neat idea to create a remote named all
for this purpose, as opposed to changing ‘origin’! That answer is really detailed and shows the process
# take an existing repo, located at remote_uri
# add a remote with that URI
> git remote add all remote_uri
# overwrite its push URI with another one
> git remote set-url --add --push all all_push_uri_overrides_main_uri
# add the original one back
> git remote set-url --add --push all remote_uri
# Two remotes now
> git remote show
all
origin
> git remote show all
* remote all
Fetch URL: remote_uri
Push URL: remote_uri
Push URL: all_push_uri_overrides_main_uri
HEAD branch: master
Remote branch:
master new (next fetch will store in remotes/all)
Local ref configured for 'git push':
master pushes to master (up to date)
I think I got it now. My error was from not understanding that adding a push URI with --add
overwrites the existing push URI, and I had to add it again to get the previous one working too.