In the middle of the desert you can say anything you want
When 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:
░░░░
██
██░░██
░░ ░░ ██░░░░░░██ ░░░░
██░░░░░░░░░░██
██░░░░░░░░░░██
██░░░░░░░░░░░░░░██
██░░░░░░██████░░░░░░██
██░░░░░░██████░░░░░░██
██░░░░░░░░██████░░░░░░░░██
██░░░░░░░░██████░░░░░░░░██
██░░░░░░░░░░██████░░░░░░░░░░██
██░░░░░░░░░░░░██████░░░░░░░░░░░░██
██░░░░░░░░░░░░██████░░░░░░░░░░░░██
██░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░░░██
░░ ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
██████████████████████████████████████████
░░
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.
Python 3.8’s Walrus1 operator is neat for printing outputs:
logger.warning(f"result is false with {start_offset=} {end_offset=} in {doc.name=}. {a.is_online=}")
[https://docs.python.org/3/whatsnew/3.8.html What’s New In Python 3.8 — Python 3.10.2 documentation] ↩︎
Was looking for something similar for months, found it in an unexpected place: Implement –pdb in a python cli
Example from there:
if "--pdb" in sys.argv:
try:
bombs()
except:
extype, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
else:
bombs()
I changed the flow to this, so I don’t need to call bombs()
in two places:
try:
bombs()
except Exception as e:
if args.pdb:
extype, value, tb = sys.exc_info()
traceback.print_exc()
pdb.post_mortem(tb)
else:
raise e
After writing if x not in y: raise ValueError()...
for the Nth time, thought of using an assert
, and you can happily do something similar:
assert x in y, f"{x} should be inside {y}"
black
formats that into
assert (
x in y
), f"{x} should be inside {y}"
which looks nice too. That’s much faster to write than my usual ValueError
pattern.
UsingAssertionsEffectively - Python Wiki touches on that, quoting from it directly below without changes.
Places to consider putting assertions:
[…]
Assertions should not be used to test for failure cases that can occur because of bad user input or operating system/environment failures, such as a file not being found. Instead, you should raise an exception, or print an error message, or whatever is appropriate. One important reason why assertions should only be used for self-tests of the program is that assertions can be disabled at compile time.
I have a lot of rarely-used personal shell scripts, all aliases now, this would be a huge improvement: Sd: My Script Directory | Hacker News
This works to lengthen the last span until the present moment (=changing it’s end to “now”):
w mod end @1 now
A good candidate for my future 220210-2236 Personal script directory :)
pkill
autocompletes running processes, which is logical but still really neat.
rjekker/i3-battery-popup is a script that does things (message, notification, sound etc.) when the battery gets low.
I installed wish
1, added i3-battery-popup -L 30
to startup.
Was this really that easy this whole time?..
(TIL - it’s a tk-based dialog thing). Gets used by the script if available. ↩︎
I want to create a qtile widget to show the currently running taskwarrior task in my statusbar.
task rc.verbose=nothing rc.color=off a
The report in ~/.taskrc
is:
# Currently active name
report.a.description='Currently active task'
report.a.columns=id,description,project
report.a.labels=ID,D,P
report.a.filter=+ACTIVE
Found out about taskw, looks really nice. First draft implementation:
from taskw import TaskWarrior
def pretty_task(act):
return f"{act['id']}/{act['description']}"
def get_task():
w = TaskWarrior()
tasks = w.load_tasks()['pending']
act = [t for t in tasks if "start" in t]
# act = [t for t in tasks]
return '_'.join([pretty_task(a) for a in act])
Returns:
19:04:27 ~/.config/qtile/cfgs/ 130
> python3 get_task.py
98/Add Taskwarrior to qtile statusbar through python binding
Couldn’t find a way to access taskwarrior’s “virtual tags” (+ACTIVE
…), so I used the fact that "start"
exists in the dictionary only if the task started.