VIM tips 5
- Use fchar or tchar to move to that char, press ";" to go next, press "," to go back.
- o creates a newline and changes to insert mode, O (capital o) creates a newline above your cursor and changes to insert mode.
- zz centers cursor position
- vi" selects everything between ". Works with ( or < as well.
- CTRL+o (older) or CRTL+i (newer) in normal mode moves between last opened files
VIM tips 4
- C deletes until the end of the line and turns on insert mode
- D deletes until the end of the line
- rx replaces the char under the cursor with x
- CTRL+n autocompletes stuff from any buffer (navigate with CTRL+n/CRTL+p)
Some "g" commands
- g; jumps to your last change (even after reopening)
- ga over a letter shows its ASCII code
- gd jumps to the corresponding definition
- gM jumps to the middle of the line
- gm jumps to the middle of the screen line
- gv reselects the previous visual area
Pacman
When I migrated from Ubuntu to Arch I had a hard time remembering Pacman's (the Arch package manager) commands. Here we go:
- pacman -Sy updates the package lists
- pacman -Su upgrades the system
- pacman -Syu updates and upgrades
- pacman -Ss
searches for installable packages - pacman -R
removes a package - pacman -Rs
removes a package and its dependencies - pacman -Qi
shows info about an installed package - pacman -Ql
list all files of an installed package - pacman -Qm show all installed AUR packages
- pacman -Qo /path/to/filename shows which package a file belongs to
- pacman -Qe lists all packages explicitly installed
- pacman -Qd lists all packages installed as a dependency for another package
- pacman -Qt searches for missed installed orphans / packages that not required by any other packages
- pacman -Fs
searches for a file in installable packages - pacman -Sc clears uninstalled packages from cache
- pacman -Scc clears all cached packages
Consider using yay as a frontend for pacman. Really convernient + fast. Plus you can manage AUR packages with it as well.
Update 2019: Nah.
I use the following aliases/bash functions in .bashrc:
alias upd='sudo pacman -Syu'
alias ins='sudo pacman -Sy'
alias aursearch='curl -s https://aur.archlinux.org/packages.gz
| zgrep'
aurinst () { pushd /home/psic4t/sys/aur &&
git clone https://aur.archlinux.org/"$1".git &&
cd "$1" && makepkg -si && popd; }
GIT for dummys
I use git only occasionally. Here are some basic commands to remember:
- git init # new repo
- git add *.go # add some files
- git commit -a -m "First commit" # make a commit
- git status # check for uncommitted changes
- git log # show commits, "--all" for all
- git diff
# shows changes - git checkout
# checkout different commit - git master # back to master
- git remote add origin git@git.sr.ht:~psic4t/bla # setup remote repo
- git push -u origin master # push to remote repo
- git tag -a "0.8.4" # tag release
- git push origin "0.8.4" # push tag to remote repo
- git clone git@github.com:mygitname/theproject.git --branch 1.0.2 # clone specific release
vim tips 3
Even more of this.
- c-o which will take you out of insert, letting you do one normal command, and then put you right back into insert.
- alt-keystroke changes to normal mode and executes keystroke
- ZQ is equivalent to :wq!
- mark some text and press ~ to switch case
- ci" removes everything between " in line and changes to insert mode
- :digraphs prints a list of key combos for characters like ©
- c-a increments number under cursor, c-x decrements number under cursor
- c-d removes indentation level in insert mode and c-t adds indentation level in insert mode
- type (partial) word. type c-x c-p for word completion. use c-n or c-p to chose the right one
Lineage OS on a Samsung Galaxy S4
Today I installed Lineage OS on an old Galaxy S4 I found in a drawer. Unfortunately the S4 is already unsupported by the LineageOS guys so you have to rely on someone on XDA developers if you don't want to compile the stuff yourself. I used this ROM.
The installation process is pretty straightforward. Install TWRP reovery fist, then LineageOS.
On your Linux box you need Heimdall installed.
INSTALL TWRP
- Connect your phone with USB
- Start the phone, hold Vol down, Power and Home for a second. The phone will boot into download mode.
Flash TWRP: heimdall flash --no-reboot --RECOVERY /path/to/twrp.img
Unplug cable when finished and shutdown phone (hold Power for 5 secs)
- Boot into recovery using Volume up and Home while pressing the power key. You can release the power key after the Samsung logo displays
You have to boot directly to recovery after flashing, otherwise TWRP gets overwritten.
INSTALL LINEAGEOS
- Put the ROM on your MicroSD card
- Boot into reovery (see above)
- Follow the instructions. I didn't flash Google Apps.
Postgres commands
Only for absolute n00bs (like me).
su - postgres
psql
\l # lists all dbs
\c dbname # connects to dbname
\dt # show tables
Create a new db:
CREATE DATABASE synapse
ENCODING 'UTF8'
LC_COLLATE='C'
LC_CTYPE='C'
template=template0
OWNER synapse_user;
Dump a db to file:
pg_dump -U postgres -W -F t mydb > /tmp/mydb.tar
W asks for password, F output file format which is 't' here, for tar
Dump all databases to file:
pg_dumpall -U postgres > /tmp/alldbs.sql
Show current processes:
select * from pg_stat_activity;
Show vacuum progress:
select * from pg_stat_progress_vacuum;
Show size of a certain db:
SELECT
pg_size_pretty (
pg_database_size ('mydatabase')
);