rails new blog --database postgresql --skip-turbolinks --skip-bootsnap --skip-spring --skip-action-text --skip-webpack-install
For an API app
rails new blog --api --database postgresql --skip-turbolinks --skip-bootsnap --skip-spring --skip-action-text --skip-webpack-install
tar --list -f backups_master_2019-07-11.tar
tar -xf TAR_FILE.tar
du -sh
df -h
curl -s -X POST -F 'par1=value' -F 'par2=value' http://HOST/PATH
OR
curl -s --data "par1=value&par2=value" http://HOST/PATH
ssh-keygen -t rsa -b 4096 -C "YOUR_EMAIL@DOMAIN.COM"
echo 'Hello. This is a number 342 for you to match' | grep -oP '(\d+\.*\d*)+'
mkdir Resized
for i in $(ls *.JPG); do convert -resize 25% $i Resized/$i; done
vcgencmd measure_temp
openssl rand -hex 12
# To take the first 5 characters
openssl rand -hex 12|head -c 5
export VERSION=v15.5.1
cd ~/Downloads
wget https://nodejs.org/dist/$VERSION/node-$VERSION-linux-x64.tar.xz
tar -xf node-$VERSION-linux-x64.tar.xz
cd node-$VERSION-linux-x64/bin
sudo rm /usr/local/bin/node
sudo rm /usr/local/bin/npm
cd /usr/local/bin
sudo ln -s /home/omar/Downloads/node-$VERSION-linux-x64/bin/node node
sudo ln -s /home/omar/Downloads/node-$VERSION-linux-x64/bin/npm npm
# Remove Stopped Containers
docker rm $(docker ps -f status=exited -q)
# Remove Dangling Images
docker rmi $(docker images -f "dangling=true" -q)
docker swarm init --advertise-addr INTERNAL_IP_ADDRESS
docker service create --replicas 3 -p 9292:9292 --host database1:DATABASE_INTERNAL_IP -e RAILS_ENV=production --name chessduo chessduo:latest
docker service scale chessduo=5
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
### Make it Permanent
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
nmap -sT -p- localhost
tar --list --file=filename.tar.gz
export PS1='$(whoami)@$(hostname):$(pwd) $ '
This command can be useful in case you want to sync some daily backups:
rsync -va --ignore-existing [HOST:]PATH [HOST:]PATH
SELECT
pt.tablename AS TableName
,t.indexname AS IndexName
,pc.reltuples AS TotalRows
,pg_size_pretty(pg_relation_size(quote_ident(pt.tablename)::text)) AS TableSize
,pg_size_pretty(pg_relation_size(quote_ident(t.indexrelname)::text)) AS IndexSize
,t.idx_scan AS TotalNumberOfScan
,t.idx_tup_read AS TotalTupleRead
,t.idx_tup_fetch AS TotalTupleFetched
FROM pg_tables AS pt
LEFT OUTER JOIN pg_class AS pc
ON pt.tablename=pc.relname
LEFT OUTER JOIN
(
SELECT
pc.relname AS TableName
,pc2.relname AS IndexName
,psai.idx_scan
,psai.idx_tup_read
,psai.idx_tup_fetch
,psai.indexrelname
FROM pg_index AS pi
JOIN pg_class AS pc
ON pc.oid = pi.indrelid
JOIN pg_class AS pc2
ON pc2.oid = pi.indexrelid
JOIN pg_stat_all_indexes AS psai
ON pi.indexrelid = psai.indexrelid
)AS T
ON pt.tablename = T.TableName
WHERE pt.schemaname='public'
ORDER BY totalrows DESC;