- command line values (for example, -u my_user, these are not variables)
- role defaults (defined in role/defaults/main.yml)
- inventory file or script group vars
- inventory group_vars/all
Problem: When running a conda environment and opening tmux on macOS, a utility called path_helper
is run again. Essentially, the shell is initialized twice which messes up the ${PATH}
so that the wrong Python version shows up within tmux
.
If using bash, edit /etc/profile
and add one line. (For zsh
, edit /etc/zprofile
)
...
What this will do:
- Trim empty lines (remove all whitespace)
- Trim whitespace at the end of code lines
- Note: it will not remove any line at all, but simply trim trailing whitespace.
Steps:
- Press
Ctrl + F
(Cmd + F
on mac) to open the search and replace view. - Toggle the regex button
.*
.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numba import njit | |
from numpy.typing import NDArray as array | |
@njit | |
def running_max(values: array, w: int) -> array: | |
"""Fast O(n) running maximum. | |
For large values of `w` this solution is 100x faster or more, than the naive version. | |
""" |
Don't do this:
The try catch will catch any instance of SomeError, even if it's not emitted inside my_async_function
.
This happens if my_async_function
runs for long enough so that SomeError
is emitted elsewhere in the
program, while this piece of code is still inside the try-except.
try:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import log10, floor | |
from decimal import Decimal as Dec | |
# Note: the method spec uses a union type float | Dec introduced in Python 3.10 | |
# Remove the type definitions to make it work with earlier versions. | |
def round_sd(x: float | Dec, sd: int = 3): | |
"""Round a value to a specified amount of significant digits `sd`. | |
""" | |
return round(x, sd - int(floor(log10(abs(x)))) - 1) |
NewerOlder