14th Week of 2022
Computer Science⚑
GNULinux⚑
(../computer_science/gnu_linux/alacritty.md)⚑
-
New: Setup remote shell automatically.
An useful
zsh
function is:s () { infocmp | ssh $@ 'tic -x /dev/stdin' ssh $@ }
Which will setup the shell always before connecting.
(../dpkg.md)⚑
-
New: Most common commands.
dpkg -S
(--search): Find package(s) owning file(s).
(../git.md)⚑
-
New: Move last n commits to a new branch.
So you forgot to create a feature branch ah? No problem, let's move the last few unpushed commits to a new branch:
git checkout -b new_branch # create a new branch from the current one git checkout old_branch # go back to the original branch git reset --hard HEAD~3 # undo the last 3 commits git checkout new_branch # go to the new branch and continue there
(../gtk.md)⚑
-
New: How to change themes.
GTK is a free and open-source cross-platform widget toolkit for creating graphical user interfaces.
To change the theme, either use
lxapparence
or manually edit~/.config/gtk-3.0/settings.ini
. You will be forced to do the second option if the theme is for gtk-3 only.
(../computer_science/gnu_linux/i3wm.md)⚑
-
New: Get pressed key name.
Some key names are hard to guess, such as
XF86AudioRaiseVolume
, and you need their name to use them in bindings. You can usexev
for that.
(../computer_science/gnu_linux/libreoffice.md)⚑
-
New: LibreOffice Calc IF().
Syntax:
IF(Test, Then Value, Otherwise Value)
.Example:
=IF(A2>500,"High","Low")
(../computer_science/gnu_linux/neomutt.md)⚑
-
New: Mailboxes commands.
c?<Tab>
: (on top of a mailbox) Shows all subdirectories and allows to open them.
(../computer_science/gnu_linux/neovim.md)⚑
-
New: Edit remote files with SSH.
Just run:
nvim scp://user@host//tmp/file
Notice the extra
/
. You can also specify just a directory to browse it interactively. -
New: Cherry pick lines to commit.
(https://github.com/tpope/vim-fugitive)
- Open the git summary with :Git (or :G).
- Expand the file which contains the lines you want to stage with
>
(or=
to toggle). This will only show the changed chunks plus some extra lines of context above and below the changed lines. V
to start visual mode and select the lines you want to stage withhjkl
.s
to stage the visual selection (or-
to toggle)- Repeat 2-4 as needed
cc
to commit
(../computer_science/gnu_linux/openldap.md)⚑
-
New: Show special entries and attributes in search.
ldapsearch +
Programming⚑
(../python_aiohttp.md)⚑
-
New: Pyhton AIOHTTP.
Basic example:
import aiohttp import asyncio async def main(): async with aiohttp.ClientSession() as session: async with session.get('http://httpbin.org/get') as resp: print(resp.status) print(await resp.text()) asyncio.run(main)
Other methods:
``python session.put('http://httpbin.org/put', data=b'data') session.delete('http://httpbin.org/delete') session.head('http://httpbin.org/get') session.options('http://httpbin.org/get') session.patch('http://httpbin.org/patch', data=b'data')
-
New: Headers.
headers = { 'Accepts': 'application/json', 'X-API_KEY': 'secret', } async with aiohttp.ClientSession(headers=headers) as session: ...
(../python_basics.md)⚑
-
New: Enumerate().
To iterate over a list keys and values use
enumerate()
. Example:some_list = for index, value in enumerate(some_list): ...
-
New: Enum.
Example:
from enum import Enum class Color(Enum): RED = 1 GREEN = 2 BLUE = 3
-
New: Enum examples.
>>> Color(1) <Color.RED: 1> >>> Color(3) <Color.BLUE: 3> >>> Color <Color.RED: 1> >>> Color <Color.GREEN: 2> >>> member = Color.RED >>> member.name 'RED' >>> member.value 1
-
New: Datetime nstance methods.
isoformat()
: ISO 8601 formatted string.
(../python_logging.md)⚑
-
New: Python logging.
Basic configuration:
import logging logging.basicConfig( format='%(asctime)s %(levelname)s %(message)s', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S' ) logging.info('Just a random string...')
(../computer_science/programming/python/pydantic.md)⚑
-
New: Pydantic types.
pydantic.HttpUrl
pydantic.color.Color
-
New: Exporting.
Options:
model.json(exclude_none=True)
model.dict(exclude_none=True)
(../computer_science/programming/python/typing.md)⚑
-
New: Awaitable type.
Awaitable
: Promise/Future.