In the middle of the desert you can say anything you want
Pytorch has torchdata, roughly similar to what I used to know and love in Keras: Tutorial — TorchData main documentation
Neat snippet I just wrote that will get rid of a lot of duplicated code:
def exception_or_error(
message: str,
fail_loudly: Optional[bool] = False,
exception_type: Optional[Type[Exception]] = ValueError,
) -> None:
"""Log error or raise an exception. Needed to control the decider
in production."""
# Raise whatever exception
if fail_loudly:
raise exception_type(message)
else:
logger.error(message)
Usage:
are_we_in_production = True
# will log or raise a ValueError based on the above
exception_or_error("File not found", fail_loudly=are_we_in_production)
# if raising something, will raise a KeyError
exception_or_error("Row not in db", fail_loudly=are_we_in_production,
exception_type = KeyError)
cloudflared:
image: cloudflare/cloudflared:latest
command: tunnel run
environment:
- TUNNEL_TOKEN=my-super-secred-tunnel-token
restart: unless-stopped
network_mode: "host"
Then whatever can run in its network with bridge driver:
networks:
nextcloud:
driver: bridge
....
services:
nextcloud:
networks:
- nextcloud
ports:
- "1234:80"
And then in the cloudflare zero trust UI add a tunnel from localhost:1234
.
Neat thing is that tunnel type HTTP refers to the connection to the host running cloudflared
, but the thing is accessible through cloudflare’s servers as both http and https. No need to manually do any certs stuff!
Wanted to run frp’s client frpc with docker to forward the SSH port.
Main issue was binding to a port already open on the host, and one not controlled by a docker thing.
My first attempt led to this: “: Error starting userland proxy: listen tcp4 0.0.0.0:22: bind: address already in use”
After looking around the Internet, found a solution.
Docker’s docker-compose.yml
:
services:
frpc:
image: chenhw2/frp
restart: unless-stopped
environment:
- ARGS=frpc
volumes:
- ./conf/frpc.ini:/frp/frpc.ini
network_mode: "host"
ports:
- "22:22"
The key being the “nertwork_mode” part.
Neither frp server nor client configs needed anything special.
Strangely , I didn’t even need to set any capabilities like I did for dns:
services:
dns:
restart: always
image: strm/dnsmasq
volumes:
- ./conf/dnsmasq.conf:/etc/dnsmasq.conf
ports:
- "53:53/udp"
cap_add:
- NET_ADMIN
This goes into “things you’re allowed to do” (Previously: List of good things - serhii.net) territory, but:
md5sum
the ISOs, otherwise that would’ve been the prime suspect<Ctrl-Shift-F2>
to go to the tty and cat /var/log/syslog
less
is not installed but nano
istty4
has live running logs
I always look in zsh history for this string:
sudo dd if=/path/to/debian-live-11.5.0-amd64-cinnamon.iso of=/not/dev/sda bs=1M status=progress
/dev/sda
is the usb drive, will be ofc. deleted fully; not a partition like /dev/sdaX
but the actual /dev/sda
disk itself.
I specifically added /not/dev/sda
at the beginning for systems where I have not set up unset zle_bracketed_paste
and that might press enter on paste or after I edit the .iso but not of
. That way I’m forced to think when editing of
.
For functions/callables, Callable
is not the entire story: you can annotate the arguments and returns values of these callables!
From mypy documentation:
The type of a function that accepts arguments
A1
,…
,An
and returnsRt
isCallable[[A1, ..., An], Rt]
."You can only have positional arguments, and only ones without default values, in callable types
If your @abstractmethod
should also be a @staticmethod
, you can
happily blend both, as long as the @staticmethod
(or other) decorator comes first.
In other words, @abstractmethod
should always be the innermost decorator.1