Python

Installation Data structures Tuple Cannot edit after it is created – Immutable. thistuple = (“1”, “2”, “3”)for x in thistuple:  print(x) List thislist = [“1”, “2”, “3”]for x in thislist:  print(x)

Databases

Postgres sudo apt install postgresqlsudo service postgresql statussudo passwd postgressudo -u postgres psql create database dbname; create user username with encrypted password ‘password’; grant all privileges on database dbname to username; Useful commands ALTER TABLE table ADD column dataType NOT NULL; \l list databases\c select database\dt list tables

Move a wordpress site to the new server

Backup mysqldump -u root -p database1 > database.sql tar -zcvf data.tar.gz data Restore CREATE DATABASE database1;CREATE USER ‘user’@’localhost’ IDENTIFIED BY ‘pwd’;GRANT ALL PRIVILEGES ON database1 . * TO ‘user’@’localhost’;FLUSH PRIVILEGES; mysql -u root -p database1 < database.sql tar -zxvf data.tar.gz new website: update wp-config.php with the new password sudo chown -R www-data:www-data /var/www/datafind /var/www/data -type… Continue reading Move a wordpress site to the new server

Ubuntu basic commands

Update packages/apps sudo apt update && sudo apt upgrade Compress/Decompress a file tar -zcvf compressedFileName.tar.gz directoryName tar -zxvf compressedFileName.tar.gz WSL use ssh key on remote server:eval ‘ssh-agent -s‘ssh-add -t 60m ~/.ssh/id_rsassh -A user:address MySQL sudo apt install mysql-server sudo mysql_secure_installation sudo /etc/init.d/mysql start sudo service mysql restart For WSL automatic start after restart: sudo update-rc.d… Continue reading Ubuntu basic commands