How to upgrade from Ubuntu Linux 16.04 to 18.04

Type the apt command or apt-get command to upgrade existing system:   sudo apt update   sudo apt upgrade Reboot the Linux box if kernel was updated   sudo reboot If you have a ufw firewall running on ufw, open ssh port 1022 using the following ufw syntax:   sudo ufw allow 1022/tcp comment 'Temp open port ssh tcp port 1022 for upgrade' Upgrade the operating system to the latest release from the command-line by typing the following command:   sudo do-release-upgrade After some time you will see “System upgrade is complete” message. Press y to restart your system to load updates kernel and operating system for your cloud server: Verification Login using the ssh command:   ssh user@your-ubuntu-server Verify Ubuntu Linux kernel version with uname:   uname -r Make sure all needed ports are open and running with the ss command or netstat command:   sudo ss -tulpn   sudo netstat -tulpn Use grep command/egrep command or tail command/cat command to verify log files for errors:    dmesg  

Copy a text of div by button click by javascript

Your html code  <input type="button" id="copyme" value="COPY THE DIV"> <div id="mypolicy">THIS IS WHAT I WANT TO COPY</div> js script $('#copyme').on('click', function(){     id =     var range = document.createRange();     range.selectNode(document.getElementById(id));     window.getSelection().removeAllRanges();   // clear current selection     window.getSelection().addRange(range);   // to select text     document.execCommand("copy");   });

Revert pushed commit from git

There are 2 way to revert pushed code using git commands 1) First Way, Let suppose your current branch name is staging and you want to revert commit from staging git log   you will see commit details   now git checkout <commit_hash_where_you_want_to_point_your_head>                 in this picture i want to remove 1st commit                 so my command will be git checkout a804a3c4662334b0aa33860548841db54fb508bb         3. Now Head will be on second commit so create new branch from here git checkout -b staging_copy (name will be depends on you)      4. Now staging_copy branch does not have reverted commit, means its code is clean       5. Now delete your staging branch from local machine git branch -D staging    6. now rename your staging_copy branch to staging git branch -M staging    7. now we need to force push to staging branch git push origin staging -f This process is lengthy and complex but we are using this because in this proc

cannot find module angular http

npm install @angular/http@latest

How to Access RabbitMQ Management Plugin rabbitmqadmin Command Line

1) Enable rabbitmq_management   sudo rabbitmq-plugins enable rabbitmq_management 2) Restart rabbitmq-server sudo service rabbitmq-server restart 3) Access GUI http://rabbitmq-server-ip:15672/ username:guest password:guest //you can check ip sudo service rabbitmq-server status command 4) Access  rabbitmqadmin Command Line http://rabbitmq-server-ip:15672/cli a) Download  rabbitmqadmin script wget http://rabbitmq-server-ip:15672/cli/rabbitmqadmin b) Change permission chmod +x rabbitmqadmin 5) rabbitmqadmin Commands a) Help ./rabbitmqadmin --help b)List all exchanges ./rabbitmqadmin -u guest -p cloud -H localhost list exchanges -u : username -p : password c) List all queues   ./rabbitmqadmin -u guest -p cloud -H localhost list queues d) Get help of subcommands ./rabbitmqadmin help subcommands ./rabbitmqadmin help subcommands | grep queue ./rabbitmqadmin help subcommands | grep exchnage ./rabbitmqadmin help subcommands | grep binding

How to Install or Uninstall Redis on Ubuntu 18.04

Step 1 – Open the terminal step 2. Update APT Repository Cache   (1)check the version table on your operating system     The package you are searching for is named redis-server. You can check its package info with apt show redis-server sudo apt-cache policy redis-server or sudo apt show redis-server The dataset is stored entirely in memory and periodically flushed to disk. (2)add PPA repository to your OS: sudo add-apt-repository ppa:chris-lea/redis-server (3)In order to install Redis, you first need to update the APT repository cache of your Ubuntu. You can do that with the following command: Update the apt-get packages index files and also update existing packages to the newest versions by using the following commands: sudo apt-get update  sudo apt-get upgrade step 2. Install Redis on Ubuntu Using the APT Command sudo apt-get install redis-server step 3. Check Redis Version redis-cli --version step 4:check if the Redis is running. Once t

lambda proc and block in rails

this all things basically we used in block level coding and for some custom queries in rails model class Main   [ 1 , 2 , 3 ].each do | num |     puts num   end end def block_method   yield end block_method { puts "Test"} def arg_method   yield   yield 1 end arg_method { |i| puts i*1 rescue nil} # explicit block def explicit_block(&block) #same as yield end explicit_block {puts "This is explicit block"} # lambda lambda_test = -> {puts "This is lambda"} lambda_test.() lambda_test[] # lambda with args arg_lambda = -> (i){ puts i}"test") my_proc = { |x| puts x } # Should work my_lambda = -> { return 1 } puts "Lambda result: #{}" # Should raise exception my_proc = { return 1 } puts "Proc result: #{}" def call_proc   puts "Before proc"   my_proc = Proc.n

unable to install ruby 2.2 in ubuntu 18.04

Try with this commands 1) Install rvm following instructions for Ubuntu on 2) rvm install ruby 2.2.10 3) rvm install ruby 2.2.10 --with-gcc=gcc if its not work then try with this  1. sudo apt purge libssl-dev && sudo apt install libssl1.0-dev 2. rvm install 2.3.5 --autolibs=disable

rails redirect after login devise

devise_scope :user do  authenticated :user do    root 'dashboard#index', as: :authenticated_root  end  unauthenticated do    root 'home#index', as: :unauthenticated_root  end end

Data Scrapping in rails

go to your terminal create a directory mkdir ruby_data_scrapping create directory mkdir lib cd lib/ touch scraper.rb gem install nokogiri  // install gems in local gem install httparty gem install byebug Write code in your scraper.rb require "httparty" require "nokogiri" require "byebug" class Scraper   attr_accessor :parse_page   def initialize       doc = HTTParty.get("")       @parse_page ||= Nokogiri::HTML(doc)   end   def get_prices      item_container.first(2){|x| x.text}   end   private     def item_container        parse_page.css(".tv-data-table__tbody").first.css(".tv-screener-table__result-row").css(".tv-screener-table__cell")     end   prices =   (0...prices.size).each do |index|       puts "Price: #{prices[index]}"   end end now run this scraper ruby scraper.rb