In the middle of the desert you can say anything you want
Yet another chapter of “python stdlib implementing most things I need better than me”, to create an infinite iterator itertools.count()
is better than stuff like iter(range(100500))
(from AA’s comment in a PR)
Couldn’t use ethernet because the device was ’not managed’ according to nm-applet
.
Neither
sudo nmcli dev set enp0s31f6 managed yes
nor changing managed=false
to managed=true
in /etc/NetworkManager/NetworkManager.conf
helped (after the usual service restarts).
But creating an this empty file did:
sudo touch /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
Memory lapse on my side, I thought tempfile.gettempdir()
returned a random temporary directory I can use. Nope, it returns the absolute address of /tmp
or its equivalent on that platform.
I was thinking about tempfile.gettempdir()
. There are also tempfile.TemporaryDirectory()
, which gets automatically removed after the context ends or the object is deleted.
It’s the kind of things I’m afraid of in shell scripts, where manually deleting a temporary directory could remove more than needed.
As usual, the python docu on topic 1 is a good thing to read.
There’s no way to remove a directory with all its contents recursively using pathlib. 2
pathlib.rmdir()
removes empty directories, pathlib.unlink()
removes files.
The way to do this is external libs, a la shutil.rmtree()
.
Very very weird design decision, as removing stuff is in no way an uncommon operation.
But a recursive pathlib solution exists, from same StackOverflow answer:
from pathlib import Path
def rmdir(directory):
directory = Path(directory)
for item in directory.iterdir():
if item.is_dir():
rmdir(item)
else:
item.unlink()
directory.rmdir()
rmdir(Path("dir/"))
orjson
looks interesting: Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy | PythonRepo
Can be run on an entire folder on right click -> “Inspect Code”
When coding in a plane and then on a bus did some slight changes, some are useful:
font_family FiraCode-Bold
font_size 12.0
If I’ll be on the road more often, I’ll create this as a mode or something - bold bigger text, different IDE colorschemes, etc.
“Octopus mode” for emergency-multitasking-stuff - heard at work (J.)
Was redesigning my website, looked if there’s a smarter way to color links based on whether they are internal/external than manually adding classes to them. Well there is: Attribute selectors - CSS: Cascading Style Sheets | MDN
Attributes can be parsed based on prefixes, suffixes, containing something, belonging to a predefined list etc.
Full list: CSS selectors - CSS: Cascading Style Sheets | MDN
Random list from the internet: Telegram Desktop Keyboard Shortcuts (hotkeys)
Here interesting is <C-S-x>
for strikethrough text. The others there are all mostly useful.
Would be neat to add some simple javascripts to the Checklists | Diensttagebuch, so that when I click each <li>
it’ll become strikethrough-d. I’d be something a la document.querySelectorAll("li")
+ somethingsomethingOnClicksomething.
javascript - Change CSS properties on click - Stack Overflow, or whatever. Filling this as “todo” for some infinite time in the future. Likely not worth spending time on, as I nether am planning to travel too much, nor want to learn more about javascript.
It kept showing a “Thesis” link in the header, I couldn’t understand where from - well, I had a file called \
, prolly a vim artifact, which was a copy of the thesis.md
I’d been blaming. Removing \
removed the link. This also breaks my assumption that jekyll will ignore any non-md non-html files, noted.
published: false
in the front matter should’ve made the post disappear, but reloading it I could see it was still there. Then I noticed it did disappear from the category listings.
The issue was my use of rsync, a line I had copypasted a long time ago:
rsync -av _site/ me@server:/whatever --progress --update
It uploads incrementally only the changed files. No one said anything about deleting the deleted ones! Jekyll didn’t generate pages for those posts, but the ones on the server stayed there.
Not quite sure whether a fix is needed, for now just removed the directory from the server.
Has nice keyboard shortcuts, viewable with ?
. Heavily vim-inspired
Deleted as they were not interesting/relevant anymore, but one of these days I’ll post my final (Russian-language) presentation somewhere here.
You can add things like someObject.someFunction()
and basically any python code there! And it starts getting evaluated immediately after adding, even without stepping through or anything similar! This will save me a lot of “Eval code” - whose last remaining purpose can then be .. is “exploratory debugging” a thing?
There’s a “Go back” action, <C-A-Left>
is the default mapping on my installation - does what it says on the box. Handy for going back after looking at the implementation of something etc etc etc. Can’t find it in the ideavim actionlist though :( Though found <C-O>
to jump to the last edited line which is very handy too:
* |CTRL-O| {@link com.maddyhome.idea.vim.action.motion.mark.MotionJumpPreviousAction}
Life keeps telling me to learn the tools I use daily, to read the entire help/manual etc - maybe one day I’ll learn to do this.
If you refactor a loop variable, such as for t in ...
, if you choose to replace strings in comments, it might replace that letter outside tokens - the “t” in “won’t”, for example. (Not that clicking “Refactor” without looking at the suggestions is ever a good idea).