This repository contains quick reference for various commands and configuration.
Test command:
export ANSIBLE_DEBUG=1
ansible -vvvv --inventory=inventory host.dev.example.com --become-user postgres -k -K -m shell -a whoami
Install requirements and run a playbook:
export ANSIBLE_VAULT_PASSWORD_FILE=$PWD/../ansible-passwords.sh
# or --vault-password-file=...
ansible-galaxy install --force -r playbooks/dev/requirements.yml -p playbooks/dev/roles
ansible-playbook -vv --inventory=inventory --become --ask-pass --ask-become-pass --tags configure_users playbooks/dev/deploy.yml
Environment variables for k8s module:
export K8S_AUTH_API_KEY=$(shell oc whoami --show-token)
export K8S_AUTH_HOST=$(shell oc whoami --show-server)
Install different version of Ansible:
virtualenv -p python2 .venv
source .venv/bin/activate
#pip install ansible==2.4
pip install ansible<2.9
# make sure that system-installed version is not used
ansible --version
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=$PWD/install ~/dev/copyq
ninja install
Remove old unnamed unused images:
podman image prune
Remove parts from the latest commit:
git reset -p HEAD^
# select parts to remove ([y]es/[n]o/[s]plit)
git commit --amend --no-edit
git commit -a -m ...
gpg --edit-key $mail trust
gpg --verbose --encrypt --recipient $mail --output $file{.gpg,}
oc -n proj get pods
oc -n proj get dc
oc -n proj describe pod web-111-abcde
oc -n proj get events
oc -n proj rollout latest dc/web
oc -n proj rsh web-111-abcde
oc -n proj scale --replicas=0 dc web
Logs:
- kail -- logs for all matching pods
kail -n proj -l deploymentconfig=web --since=1h
kail -n proj -l service=web --since=20m
Avoid using additional resources on deployment:
---
apiVersion: v1
kind: DeploymentConfig
spec:
strategy:
type: Rolling
rollingParams:
maxSurge: 0
# ...
psql "host=db.dev.example.com user=$user dbname=$db sslmode=require"
Python 3 virtualenv:
python3 -m venv .venv
source .venv/bin/activate
Python 2 virtualenv:
virtualenv -p python2 .venv
source .venv/bin/activate
Breakpoint:
import ipdb; ipdb.set_trace()
Breakpoint in Python 3.7:
breakpoint()
export PYTHONBREAKPOINT=0
export PYTHONBREAKPOINT=pdb.set_trace
export PYTHONBREAKPOINT=ipdb.set_trace
Profiling decorator:
def profile(func):
import cProfile
import functools
import io
import pstats
@functools.wraps(func)
def wrap(*args, **kwargs):
pr = cProfile.Profile()
pr.enable()
result = func(*args, **kwargs)
pr.disable()
s = io.StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats(pstats.SortKey.TIME)
ps.print_stats()
print(s.getvalue())
return result
return wrap
@profile
def foo():
pass
:windo difft
-- diff open windows:setl ar
-- automatically reload file if changed:read
-- open file read onlyq/
-- search historyq:
-- command historygf
-- open file which filename is under cursorgi
-- go to last insert mode placeg;
-- go to last changeg,
-- go to next changegq
-- reformat~
-- change case of letter:g/PATTERN/norm ...
-- do something with each matched line (e.g. delete withdd
):args **/*.h | vert sall
-- open all matching files- https://www.reddit.com/r/vim/wiki/vimrctips
- Powerlevel10k -- fast status line
ALT-H
-- show command helpC-x C-e
-- edit command line