This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -R 5000:to_ip:22 root@from_ip 'rsync -e "ssh -p 5000" -vuar from_path/* localhost:to_path' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fdisk -l # /dev/sda hdd 1, /dev/sdb hdd 2, etc | |
fdisk /dev/sdb. #chooose desired disk | |
# press m for help, press n to create partition, press w to save changes | |
partprobe # inform system about changes | |
mkfs -t ext4 /dev/sdb1 # format partition | |
mkdir /disk1 # create mount point | |
mount /dev/sdb1 /disk1 # mount created partition | |
# make mount permanent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo firewall-cmd --permanent --zone=public --add-service=https --add-service=http | |
sudo firewall-cmd --permanent --zone=public --add-port=3306/tcp. | |
sudo firewall-cmd --reload | |
sudo firewall-cmd --permanent --list-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo dnf install chrony -y | |
sudo systemctl enable chronyd | |
sudo systemctl start chronyd | |
timedatectl set-ntp true | |
timedatectl status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grep -rl "old" . | xargs sed -i '' 's/old/new/g' | |
escape single quote with: '\'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yum install cloud-utils-growpart -y | |
df -hT | |
lsblk | |
sudo growpart /dev/xvda 1 | |
sudo xfs_growfs -d / | |
partprobe # for system recognition | |
pvresize /dev/xvda 1 | |
lvextend -r centos/root /dev/xvda1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Access keys or properties of array or object | |
* @variable array|object - array or object variable | |
* @key_list array|string - list of keys, valid inputs are: ['key1', 'key2'], 'key1', 'key1->key2->key3', etc. | |
* @default_value mixed, the default value to return if key/property does not exist | |
*/ | |
function get_key($variable, $key_list, $default_value=null) { | |
if (!isset($variable)) return $default_value; | |
if (is_string($key_list)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# random between 10 and 5 | |
select FLOOR(RAND()*(10-5+1)+5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var table_selector = '#table_id'; | |
var i = 0; | |
var content_length = 15; | |
document.querySelectorAll(table_selector + ' tr').forEach((row, i) => { | |
row.querySelectorAll('td').forEach((td, j) => { | |
td.innerHTML = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, content_length); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
su - postgres | |
psql | |
# change user password | |
ALTER USER user_name WITH PASSWORD 'new_password'; | |
\l #list databases | |
\c db_name # use database | |
\dt # list tables |
NewerOlder