Resize JPG images using ImageMagick

mkdir Resized
for i in $( ls *.JPG); do convert -resize 28% $i Resized/$i; done

Installing Node.JS on Linux

export VERSION=v12.6.0
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
if [ -f "/usr/local/bin/node" ]; then
sudo rm /usr/local/bin/node
fi
if [ -f "/usr/local/bin/npm" ]; then
sudo rm /usr/local/bin/npm
fi
sudo ln -s node /usr/local/bin/node
sudo ln -s npm /usr/local/bin/npm

Docker Useful Shortcuts

# Remove Stopped Containers
docker rm $(docker ps -f status=exited -q)
# Remove Dangling Images
docker rmi $(docker images -f "dangling=true" -q)

Git Pull Remote Branch

git checkout --track origin/remove_branch

Start Postgres/Solr in Docker

docker network create todo
docker run --name todo_database --network todo -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=test123 -e POSTGRES_DB=todo -d postgres:9.6
docker run --name todo_solr --network todo -d -p 8983:8983 -t solr:7.5.0-slim
docker exec -it --user=solr todo_solr bin/solr create_core -c core1
docker run --name todo_app -v /root/web_storage:/app/public/storage --network todo -p 4001:4000 -d develop.qunsul.com:5043/todo

Ruby Sample Solr Code

require 'uri'
require 'rsolr'
solr = RSolr.connect :url => 'http://localhost:8983/solr/core1'
response = solr.get 'select', :params => {:q => '*:*'}
response = solr.get 'select',
:params => {:q => 'title:*Qunsul*'}
response = SOLR.get 'select', :params => {q: 'type:User', sort: 'rate desc', start:0, rows: 15}; nil
response["response"]["docs"]
solr.delete_by_query '*:*'
documents = [{:id=>1, :price=>1.00, :title => "omar", :body => "qunsul"}, {:id=>2, :price=>10.50, :title => "Jordan", :body => "Amman is the capital of Jordan"}]
solr.add documents
solr.commit

Docker Swarm Init / Start a Service

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

Add Swap Memory to Linux Virtual Machine (Works on Digital Ocean)

sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h