In the middle of the desert you can say anything you want
find -size 0 -print -delete
, or find /foldername -size 0 -print -delete
.1
balenaEtcher - Flash OS images to SD cards & USB drives is mentioned in the official Mint installation guide1 and is quite neat!
No support for persistant storage like the good old unetbootin, but I guess still higher-level than dd
.
functools
has lru_cache
, really easy to add it as decorator to a function to cache the responses! Example directly copied from caching - Python in-memory cache with time to live - Stack Overflow:
from functools import lru_cache
import time
@lru_cache()
def my_expensive_function(a, b, ttl_hash=None):
del ttl_hash # to emphasize we don't use it and to shut pylint up
return a + b # horrible CPU load...
def get_ttl_hash(seconds=3600):
"""Return the same value withing `seconds` time period"""
return round(time.time() / seconds)
# somewhere in your code...
res = my_expensive_function(2, 2, ttl_hash=get_ttl_hash())
# cache will be updated once in an hour
Used it practically in some code that called an expensive external function multiple times. Bad code I didn’t have time to fix, but it took 2.5 seconds to run. Adding the lines above shortened the runtime from ~2.5 seconds to 0.02 seconds with cache lifetime of 60 seconds.
Didn’t update the function at all without the del ttl_hash
and default none parameter bit, TODO understand what’s really happening there.
This is really cool and of course historical document processing is an established research area: Introduction — dhSegment documentation
Git doesn’t track permissions, except whether the file is executable for the current user. 1
To recursively set all files (but not directories, because then you can’t ls
them…) to not-executable:
find . -type f -print0 | xargs -0 chmod -x
To unset this for current repo (--global
to unset this globally):
git config --local core.fileMode false
Goal: convert “2010-01-01” into “Day 1234”.
First tried to create a Hugo shortode, but you can’t use a shortcode inside a template:
Process: loading templates: ".../index.html:84:1": parse failed: template: index.html:84: unexpected "<" in command
Next step - a partial template! To call them one uses {{ partial templatename .}}
, with .
being the “context”. I passed .Key
, that has the groupBy date, and it works.
So, the partial template day.html
does ugly math to get the number of days since the first day of 2019:
{{ $date := (printf . | time) }}
{{ $startUnix := (printf "2019-01-01" | time) }}
{{ $diff := sub $date.Unix $startUnix.Unix }}
{{ $diffInDays := div $diff 86400}}
{{ $diffInDays }}
Then I use it inside templates like this:
<h2 class="title day">
{{ partial "day.html" .Key }}
</h2>
“Hugo uses Go’s html/template and text/template libraries as the basis for the templating.” 1
I tried to use go
as “language” in code blocks to highlight Hugo templates and it seems to work nicely!
The result of
```go
{{ range (.Paginate ($pages_l.GroupByDate "2006-01-02")).PageGroups }}
```
is
{{ range (.Paginate ($pages_l.GroupByDate "2006-01-02")).PageGroups }}
(I generated the first code listing using the \{-{-< highlight go >\}\}
Hugo shortcode)
Previously I had the posts split by days (“Day 1234”), now for every former h2-header I have a separate post, but still want to split them by days.
Hugo can group posts by stuff, including by dates. 1
This kinda works with pagination. 2
Now my list.html
template for Diensttagebuch uses this to iterate through days/groups:
{{ $pages_k := where .RegularPagesRecursive ".Parent.Title" "Days" }}
{{ $pages_j := where $pages_k "Params.draft" "ne" true}}
{{ $pages_l := where $pages_j "Params.hidden" "ne" true}}
{{ range (.Paginate ($pages_l.GroupByDate "2006-01-02")).PageGroups }}
With the important bit being here, this iterates by day, not by month as in the examples:
$pages_l.GroupByDate "2006-01-02"
Then the “day” header itself is {{.Key}}
, to get the day of the month + month-year I do this:
<span class="day">{{ dateFormat "02" .Key }}</span>
{{ dateFormat "Jan 2006" .Key }}
Then iterating through the individual posts inside each “day” is:
{{ range .Pages }}
<a href="{{ .RelPermalink }}">{{.Title}}</a>
<span class="description">
{{ .Content }}
</span>
{{ end }}
Everything that has to do with grouping and lists described here: Lists of Content in Hugo | Hugo) ↩︎
nvidia-smi
has a python library: nvsmi · PyPI
import nvsmi
nvsmi.get_gpus()
nvsmi.get_available_gpus()
nvsmi.get_gpu_processes()
RabbitMQ is a message broker / scheduler that allows sending/receiving messages.
RabbitMQ is a message broker: it accepts and forwards messages. You can think about it as a post office: when you put the mail that you want posting in a post box, you can be sure that the letter carrier will eventually deliver the mail to your recipient. In this analogy, RabbitMQ is a post box, a post office, and a letter carrier.
The major difference between RabbitMQ and the post office is that it doesn’t deal with paper, instead it accepts, stores, and forwards binary blobs of data ‒ messages.