In the middle of the desert you can say anything you want
[Code]-Drop Rows with Non-Numeric Entries in a Column (Python)-pandas shows one way to do this using pd.to_numeric()
1:
df['Gm#'] = pd.to_numeric(df['Gm#'], errors='coerce')
df = df.dropna(subset=['Gm#'])
Select the lines to sort, then :sort
.
When you’re looking at two files in two separate splits, :diffthis
is the magic command.
Neat for manually diffing parts of jsons.
Previously: 230313-1423 json diff with jq
_
Wanted w
/b
in python not to skip over underscores, that is consider underscores word separators.
set iskeyword?
shows the current/default value:
iskeyword=@,48-57,,_,192-255
iskeyword=@,48-57,_
Not digging to deep, removing _
gives me the wanted behaviour. Python got even easier now. (Keeping the ~/.vimrc
as-is though).
EDIT: OK, but this breaks <C-*>
and I can’t quickly jump between functions. Sad :( Rolling back…
IdeaVim supports camel case motions! Of course it does: ]w
, [w
, ]b
, [b
I’m happy for my custom keyboard layout where brackets are REALLY close and usable. I love this.
But for pycharm, remapped them, giving me what I want:
map w [w
map e ]w
map b [b
When using black, this cryptic message
error: cannot format /experiment.py: cannot use --safe with this file; failed to parse source file.
happens to me only when I have a stray trailing comma in my imports:
from typing import Optional, Tuple,
a_{multiplechars}
|modulo|
Problem: jupyter notebooks being shown as text on my website.
Adding the following to a .htaccess
file prevents files being “shown” in the browser, as opposed to downloaded1:
<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt|ipynb)$">
Header set Content-Disposition attachment
</FilesMatch>
Also 2 that there’s a HTML syntax for that in links now!
<a href="./my_file.txt" download>
ls
has --color=always
, but not everyone does.
sudo apt install expect-dev
provides unbuffer
1, that when prefixed to a command makes it think it’s running in an interactive CLI, even if it’s piped or redirected etc.
For example this would preserve the colors in timew month
’s output while changing text:
unbuffer timew month 2022-02-01 - 2022-04-01 | sed "s/what/ever/g"
Was trying to code a “is this a sortable thing or not” thing, saw the documentation for collections, and it’s awesome: collections.abc — Abstract Base Classes for Containers — Python 3.11.3 documentation
The table of base classes has who inherits from whom (Set
from Collection
), which abstract methods it has (__contains__
) etc.
Definitely worth reading in full. As the rest of the very very readable Python docs.
> history
10640 echo command 1
10641 echo command 2
10642 echo command 3
Usually I’d !10640 !10642
to run 1 and 3, but there’s fc
!1
fc -l
to list instead of invoke.
fc first last
, where the latter ones can be e.g:
12
for command 12-12
for command executed 12 commands agoThen:
> fc -l 10639
10639 h apt
10640 echo command 1
10641 echo command 2
10642 echo command 3
10643 history
> fc -l 10639 10642
10639 h apt
10640 echo command 1
10641 echo command 2
10642 echo command 3
> fc 10639 10642
% opens vim with these commands, edit then they get run on close.
Never thought about this till I saw this:
./file.sh
zsh: permission denied: ./file.sh
I’d usually chmod +x
it, but sh file.sh
works just as well!