Some reminders for my future self.
Save the current layout, and later set the layout to it.
tmux list-windows
will give you
1: man* (3 panes) [274x62] [layout 5ba8,274x62,0,0{181x62,0,0,0,92x62,182,0[92x31,182,0,48,92x30,182,32,49]}] @0 (active)
...
then
tmux select-layout layout 5ba8,274x62,0,0{181x62,0,0,0,92x62,182,0[92x31,182,0,48,92x30,182,32,49]}
Add a key binding to this command in .tmux.conf
.
git log -p filename
git commit --amend
: git reset --soft HEAD@{1}
git add
: git reset filename
createuser -d -s -r
-d
: user can create database-s
: user is superuser-r
: user can create rolesALTER TABLE "article" ADD COLUMN "password" character varying(80) NULL;
psql
:
\l
: list all databases\dt
: list all tables in the current database\connect dbname
: switch database\d+ tablename
: describe the table schemaList databases:
SELECT datname FROM pg_database
WHERE datistemplate = false;
List tables in the current database:
SELECT table_schema,table_name
FROM information_schema.tables
ORDER BY table_schema,table_name;
(source: How do I list all databases and tables using psql?)
pg_dump -d dbname -f filename.dump
pg_restore -d dbname -j 8 filename.dump
(-j
: number of concurrent jobs)Set password:
ALTER ROLE psusername WITH PASSWORD 'password';
.mode column
.headers on
mysqldump -u root -p dbname > db.sql
mysql -u root -p dbname < db.sql
create database mydb
create user 'myuser'@'localhost' identified by 'password';
grant all privileges on mydb.* to 'myuser'@'localhost' with grant option;
insert into table_name values ( , , );
update table_name set column1=expr1, column2=expr2 where conditions;
How to export result in CSV:
SELECT order_id,product_name,qty FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(from Save MySQL query results into a text or CSV file)
Remove .pyc
:
find . -name "*.pyc" -delete
curl
basic usage:
curl
url
-H 'X-Auth-Key: 1234'
-H 'Content-Type: application/json'
-X PUT
-d '{"user": "me"}'
-F 'username=foo'
-D - # print header
Unpacking .tar.gz
is tar -xvzf
. Packing is:
tar -zcvf archive-name.tar.gz directory-name
Remove the first line in pipe:
tail -n +2 -f -
sed 1d
awk 'NR > 1'
Substitute in a file:
sed -i 's/teh/the/g' path/to/file
Delete lines in a file that contains a specific string:
sed -i '/pattern to match/d' path/to/file
Count lines of Haskell code:
find . -type d \( -path './.git' -o -path './.stack-work' \) -prune -o -name '*.hs' | xargs wc -l
browser.fixup.alternate.enabled
browser.fullscreen.animate
toolkit.cosmeticAnimations.enabled
sudo apt-get install openssh-server
ssh-keygen -t ed25519 -f path/to/file
ssh-keygen -lf ~/.ssh/id_ed25519.pub
sshfs
without root privilege: fusermount -u /path/to/mount
sshfs
: sshfs -o reconnect server:/path/to/mount
Delete user account:
userdel username
sudo update-grub
sudo systemctl restart wpa_supplicant@wlp1s0.service
wpa_cli -iwlp1s0
list_networks
scan_results
Allow self-signed certs:
/set irc.server.example.ssl_verify off
(from Weechat FAQ)
Source: pacman - ArchWiki
Clear cache:
The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default:
paccache -r