In the middle of the desert you can say anything you want
Pressing u / d moves you through the individual frames of the stack.
Also TODO look into using it to run stuff and debug automatically on fail, without editing the source code.1
An Inverted index - Wikipedia is a mapping from content to its location/name, as opposed to the usual case of name-to-content. One use is searching.
This is part two of 211209-1354 Python testing basics with poetry and pytest. Fixtures scopes work similarly to the various setup/teardown functions of unittest, can be per module/class/etc.
@pytest.mark.xfail(reason="Reason why it's supposed to fail")
def test_...
For a specific exception, you assert that it raises that exception type and then can do asserts on the exception that is raised.
def test_whatever():
with pytest.raises(Exception) as excinfo:
raise Exception("oh no")
assert str(excinfo.value) == "oh no"
Regex also works (example directly from pytest.raises()
API Reference
>>> with pytest.raises(ValueError, match=r'must be \d+$'):
... raise ValueError("value must be 42")
## Services (skipped, see below)
### Creating fixtures that get used automatically
```python
@pytest.fixture(autouse=True)
def skip_servicetest(request, run_services):
if request....
pytest.skip("skipped because X")
pyfakefs
creates a fake filesystem that gets used transparently.
from pyfakefs.fake_filesystem import FakeFilesystem
@pytest.fixture
def common_fs(fs: FakeFilesystem):
fs.create_dir(Path("/tmp/common"))
fs.create_file("/tmp/common")
def test_filesystem_fixture(common_filesystem):
assert os.path.exists("/tmp/common")
assert os.path.exists("/tmp/not_there") == False
A development approach from TDD.
Tests should be:
3A is a common pattern for structuring tests.
In a test this would look like this:
string = "ABc"
result = string.upper()
assert result == "ABC"
import this
A coworker reminded be of this gem; quoting him:
The order is important. My favourite one is ’explicit is better than implciit'
Had a big repo, wanted to clone only some folders.
The setup below automatically fetched the subfolders I added to the sparse-checkout set.
git clone --filter=blob:none --no-checkout --branch main ssh://git@me.me/my/repo.git
cd myrepo
git sparse-checkout init --cone
git sparse-checkout set "activitywatch" "friends" ".task" ".timewarrior"
https://gohugo.io/tools/search/
It boils down to creating an index (json) then using something to search in it client side
Once an index is built, Lunr seems the way to do with this: https://lunrjs.com/docs/lunr.Query.html#~Clause
It seems flexible enough, including ability to search inside taxonomies.
~/.dotfiles
for stow to work# essentials
sudo apt install cowsay fortune-mod
sudo apt install vim-gtk3 # for clipboard support
# wm clipboard
sudo apt install i3
sudo apt installxdotool maim xclip zenity
# misc
sudo apt install jq tldr silversearcher-ag rofi xscreensaver
sudo apt install blueman
sudo apt install tree stow
sudo apt install fish
sudo apt install taskwarrior timewarrior
sudo apt install arandr, autorandr
# if needed ensurepip
sudo apt install python3.12-venv
sudo apt install git git-lfs
sudo apt install tig
sudo apt install pavucontrol
#sudo apt install kitty
sudo apt install alacritty
sudo apt install htop
sudo apt install ncal # cal command
uv task install
gem install friends
brew install hugo
brew install go-task
brew install asciiquariume
npx pagefind
(for hugo)chsh /usr/bin/fish
tlp
if it’s a laptop~/.fonts
should work, subdirectories possible
fc-cache -v
tells you which dirs it goes throughfc-cache -f
installssudo apt install fonts-firacode
alias cal="ncal -w -A1 -M" # week starts on monday, 1 months from now, show weeks
From SO1, if both are JSON serializable objects, you can use json
:
from json import loads, dumps
from collections import OrderedDict
def to_dict(input_ordered_dict):
return loads(dumps(input_ordered_dict))
Scripting Commands — Qtile 0.1.dev50+ga708c8c.d20211209 documentation has a lot more interesting stuff than the ones exposed through “vanilla” config, finally figured out how to use them:
def test(qtile):
qtile.cmd_to_layout_index(0)
# ...
Key([mod, ctrl], "apostrophe", lazy.function(test))
It’s in the docu1 but I missed its significance on first read, then saw hints in a github config2.
The qtile
object passed as the first argument is exactly the QTile
from scripting.
To parametrize it, you have to let it return a callable function:
def switch_to(ly_id: int):
def cb(qtile):
qtile.cmd_to_layout_index(ly_id)
return cb
# ...
Key([mod, ctrl], "apostrophe", lazy.function(switch_to(0))),
I don’t see this mentioned in the docu, but the attributes can be found in the source of libqtile.core.manager — Qtile 0.1.dev50+ga708c8c.d20211209 documentation.
If you mess up config.py
and restart qtile and most of your keybindings aren’t working, if you’re lucky you still have a terminal open. From it, you can fix config.py, then restart via qtile shell
-> restart()
.