Ruby (Programming Language)

Ruby (Programming Language)
Tutorial Title: Ruby (Programming Language)

Course: Web Engineering

Instructor: Muhammad Samim


Note: Copy and paste commands in terminal (irb) after sign >



1. Displaying message and calculating values
  • Open terminal by pressing Ctrl + Alt + t
  • type irb and press enter now you can apply following Ruby commands
  • > "Hello Everyone"
  • > puts "Hello Everyone"
  • > 3 + 3
  • > 4  * 4
  • > 5 ** 6    (** means 5^6)
2. Comments
  • # sign is used for comments eg.
  • > 20 + 30 # Adding two integers
3. Strings
  • For string "" are used e.g
  • > "Ruby Language"
  • > "" #Empty string
4. Concatenating
  • + sign is used for concatenating eg.
  • > "Ruby" + "Language"
5. Variables
  • Ruby auto detect data type of variables so no need to specify data type for variables
  • > b = 4 + 4
  • > a = "Any Message"
  • > first_name = "Muhammad"
  • > last_name = "Samim"
  • > first_name + " " + last_name #Displaying first name and last name together.
6. Interpolation (Built in function of Ruby)
  • Math.sqrt(99)
  • Math.cos(30)
7.

Creating web application on Ruby on Rails without scaffold

Tutorial Title: Creating web application on Ruby on Rails without scaffold

Course: Web Engineering

Instructor: Muhammad Samim


Note: Copy and paste commands in terminal after dollar sign ($)



1.CREATING AN APP
  • Open terminal by pressing Ctrl + Alt + t
  • $ mkdir webApps
  • $ cd webApps
  • $ rails new blog -d postresql
2.  CREATING HOME PAGE CONTROLLER
  • $ rails generate controller home index
3. GO TO home/webApps/blog/app/view/home/index.html.erb TYPE OR PASTE BELLOW HTML CODE AND SAVE IT.
  •  <h1> Welcome to Home Page </h1>
4.  CREATING DATABASE AND MIGRATING TO SHOW PAGES ON BROWSER
  • $ rake db:create
  • $ rake db:migrate
 5. OPEN YOUR BROWSER AND TYPE THE LOCALHOST ADDRESSES TO CHECK
  • localhost:3000  (for home page)
  • localhost:3000/home/index
6. MAKING HOME/INDEX FILE AS YOUR HOME PAGE
  • Go to home/webApps/blog/config/routes.rb and type the    following  codes
  •  get 'home/index' 
  •  root 'home#index'
7.   OPEN YOUR BROWSER AND type localhost addresses to check
  • localhost:3000  (for home page)
  • localhost:3000/home/index
8.  MAKING ROUTES FOR YOUR DIFFERENT PAGES
  • go to home/webApps/blog/config/routes.rb and add following code
  • resources :articles
  • it will create routes for articles#index, articles#create, articles#new, articles#edit, articles#show, articles#update, articles#destroy 
9. TO CHECK ROUTES OF PAGES TYPE THE FOLLOWING COMMAND
  • $ rake routes
10.  CREATING CONTROLLER FOR ARTICLES TO DEFINE PAGES OF ARTICLES MADE BY resources :articles
  • $ rails generate controller articles
11. GO TO home/webApps/blog/app/controller/articles_controller.rb AND ADD THE FOLLOWING CODES
  • def new
     end
12. CREATING new.html.erb FILE
  • Go to home/webApps/blog/app/view/
  • Right click>New Document> New Document. Rename and save with name new.html.erb > open it and type the bellow code
  •  <h1> New Page of Articles </h1>
13.  CREATING FORM USING RUBY LANGUAGE
 go to home/webApps/blog/app/view and open new.html.erb and paste the following Ruby Code and save
  • <%= form_for :article, url: articles_path do |f| %>
    <p>
    <%= f.label :title %><br>
    <%= f.text_field :title %>
    </p>
    <p>
    <%= f.label :body %><br>
    <%= f.text_area :body%>
    </p>
    <p>
    <%= f.submit %>
    </p>
    <% end %>
14. OPEN YOUR BROWSER AND GO TO THE LINK TO CHECK THE CREATED FORM
  •  localhost:3000/articles/new
 15. CREATING THE ARTICLES MODEL TO SAVE THE DATA FROM USER
  •  $ rails generate model Article title:string body:text
  •  $ rake db:migrate
16.  CREATING THE CREATE PAGE OF ARTICLES TO SAVE THE DATA go to home/webApps/blog/app/controllers and open articles_controller.rb file and add the following code (after def new end) and save file.
  • def create
    @article = Article.new(article_params)
    @article.save
    redirect_to @article
    end
    private
    def article_params
    params.require(:article).permit(:title, :body)
    end
17.  DEFINING SHOW PAGE IN ARTICLE CONTROLLER
go to home/webApps/blog/app/controllers and open articles_controller.rb file and add the following code
Note: you must define it on the top (before def new end )
  • def show
    @article = Article.find(params[:id])
    end
18. CREATING show.html.erb FILE TO SHOW WHAT ARE SAVED IN CREATE
go to home/webApps/blog/app/view
  • Right click > New Document > Empty Document. Rename file and save with name show.html.erb. Open it and save the following Ruby codes
  • <p>
    <strong>Title:</strong>
    <%= @article.title %>
    </p>
    <p>
    <strong>Text:</strong>
    <%= @article.body %>
    </p>
19.  DEFINING INDEX PAGE TO LIST ALL SAVED DATA (ARTICLES)
  • go to home/webApps/blog/controllers/ and open articles_controller.rb and add the following code
Note: now it must be on top (before def show end)
  • def index
    @articles = Article.all
    end
20. CREATING index.html.erb FILE TO LIST ALL SAVED DATA IN ONE PAGE
  • go to home/webApps/blog/app/view
  • Right click > New Document > Empty Document. Rename file and save with name index.html.erb. Open it and save the following Ruby codes
  •  <h1>Listing articles</h1>
    <table>
    <tr>
    <th>Title</th>
    <th>Text</th>
    </tr>
    <% @articles.each do |article| %>
    <tr>
    <td><%= article.title %></td>
    <td><%= article.body %></td>
    </tr>
    <% end %>
    </table>
21.  LINKING PAGES WITH EACH OTHER ADDING LINK OF ARTICLE IN HOME PAGE
  • go to home/webApps/blog/app/view/home and open index.html.erb file and add the following codes of Ruby
  •  <%= link_to 'My Blog', controller: 'articles' %>
22.  ADDING LINK OF NEW ARTICLE IN ARTICLES INDEX PAGE
  • go to home/webApps/blog/app/views/articles/ and open index.html.erb file and add the following codes of Ruby
  •  <%= link_to 'New article', new_article_path %>
23.  ADDING LINK OF INDEX PAGE OF ARTICLES IN NEW PAGE OF ARTICLE (FORM)
  •  <%= link_to 'Back', articles_path %>
24. ADDING LINK OF INDEX PAGE OF ARTICLES IN SHOW PAGE OF ARTICLE
  • go to home/webApps/blog/app/views/articles/ and open show.html.erb file and add the following codes of Ruby
  • <%= link_to 'Back', articles_path %> 
25. ADDING VALIDATIONS (APPLYING SOME RULES)
  • go to home/webApps/blog/app/models open articles.rb file and add following codes
  • validates :title, presence: true,
    length: { minimum: 5 }
 26. 6. AFTER ADDING VALIDATION THE @article.save RETURNS FALSE, SO WE NEED TO CATCH THE ERROR AND KEEP THE USER ON THE SAME FORM.
  • go to home/webApps/blog/app/controllers and open articles_controller.rb file and modify the code (replace both definition completely with old ones)
  • def new
    @article = Article.new
    end
  • def create
    @article = Article.new(article_params)
    if @article.save
    redirect_to @article
    else
    render 'new'
    end
    end
27. MODIFYING SOME CODES TO SHOW THE CAUGHT ERROR IN NEW PAGE OF ARTICLES (REPLACE OLD CODES WITH BELLOW CODE COMPLETELY)
  • Go to home/webApps/blog/app/view and open new.html.erb and replace old codes with bellow codes completely.
  • <%= form_for :article, url: articles_path do |f| %>
    <% if @article.errors.any? %>
    <div id="error_explanation">
    <h2>
    <%= pluralize(@article.errors.count, "error") %> prohibited
    this article from being saved:
    </h2>
    <ul>
    <% @article.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
    </ul>
    </div>
    <% end %>
    <p>
    <%= f.label :title %><br>
    <%= f.text_field :title %>
    </p>
    <p>
    <%= f.label :body %><br>
    <%= f.text_area :body %>
    </p>
    <p>
    <%= f.submit %>
    </p>
    <% end %>
    <%= link_to 'Back', articles_path %>
28. DEFINING EDIT PAGE IN ARTICLES CONTROLLER TO MAKE IT ABLE TO BE UPDATED
  • go to home/webApps/blog/app/controllers and open articles_controller.rb and add bellow codes bellow (def new (code) end)
  • def edit
    @article = Article.find(params[:id])
    end
29. CREATING edit.html.erb file TO EDIT SAVED RECORDS
  • Go to home/webApps/blog/app/views/articles Right click > New Document > Empty Document. Rename it with edit.html.erb. Open and paste bellow codes of Ruby
  •  <h1> Welcome to Edit Page of Articles </h1>
    <%= form_for :article, url: article_path(@article), method: :patch do |f| %>
    <% if @article.errors.any? %>
    <div id="error_explanation">
    <h2>
    <%= pluralize(@article.errors.count, "error") %> prohibited
    this article from being saved:
    </h2>
    <ul>
    <% @article.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
    </ul>
    </div>
    <% end %>
    <p>
    <%= f.label :title %><br>
    <%= f.text_field :title %>
    </p>
    <p>
    <%= f.label :body %><br>
    <%= f.text_area :body %>
    </p>
    <p>
    <%= f.submit %>
    </p>
    <% end %>
    <%= link_to 'Back', articles_path %>
 30. DEFINING UPDATE ACTION IN ARTICLES CONTROLLER
  • Go to home/webApps/blog/app/controllers and open articles_controller.rb and add bellow codes bellow (def edit (codes) end)
  • def update
    @article = Article.find(params[:id])
    if @article.update(article_params)
    redirect_to @article
    else
    render 'edit'
    end
    end
31. ADDING LINK OF EDIT TO MODIFY THE SAVE RECORDS IN INDEX PAGE OF ARTICLES
  • go to home/webApps/blog/app/views/articles/ and open index.html.erb file and replace bellow codes with old codes completely
  • <h1> Welcome to index page of Articles </h1>
    <table>
    <tr>
    <th>Title</th>
    <th>Text</th>
    <th colspan="2"></th>
    </tr>
    <% @articles.each do |article| %>
    <tr>
    <td><%= article.title %></td>
    <td><%= article.body %></td>
    <td><%= link_to 'Show', article_path(article) %></td>
    <td><%= link_to 'Edit', edit_article_path(article) %></td>
    </tr>
    <% end %>
    </table>
    <%= link_to 'New article', new_article_path %>

32. IF TWO PAGES USE SIMILAR CODES THEN WE MAKE ONE PARTIAL PAGE HOLDING BOTH CODES AND THEN WE CALL PARTIAL PAGE IN EACH PAGE TO CLEAN UP DUPLICATION.
  • Go to home/webApps/blog/app/views/articles and Right click > New Document > Empty Document. Rename it with name _form.html.erb then open it and paste bellow codes of Ruby and save
  • Note: When ever we make partial page that will be started from underscore  then page name eg. _form.html.erb
  • <h1> Using one partial page and calling in different pages </h1>
    <%= form_for @article do |f| %>
    <% if @article.errors.any? %>
    <div id="error_explanation">
    <h2>
    <%= pluralize(@article.errors.count, "error") %> prohibited
    this article from being saved:
    </h2>
    <ul>
    <% @article.errors.full_messages.each do |msg| %>
    <li><%= msg %></li>
    <% end %>
    </ul>
    </div>
    <% end %>
    <p>
    <%= f.label :title %><br>
    <%= f.text_field :title %>
    </p>
    <p>
    <%= f.label :body %><br>
    <%= f.text_area :body %>
    </p>
    <p>
    <%= f.submit %>
    </p>
    <% end %>
33. DELETING CODE OF new.html.erb AND CALLING PARTIAL PAGE CODE BECAUSE WE KEPT CODE OF new.html.erb IN PARTIAL PAGE _form.html.erb
  • Go to home/webApp/blog/app/views/articles and open new.html.erb file and replace old codes with bellow code completely.
  • <h1> New page of Articles </h1>
    <%= render 'form' %>
    <%= link_to 'Back', articles_path %>
34. DELETING CODE OF edit.html.erb AND CALLING PARTIAL PAGE CODE BECAUSE WE KEPT CODE OF edit.html.erb IN PARTIAL PAGE _form.html.erb
  • Go to home/webApp/blog/app/views/articles and open edit.html.erb file and replace old codes with bellow code completely.
  • <h1> Edit page of Articles </h1>
    <%= render 'form' %>
    <%= link_to 'Back', articles_path %>
35.  DEFINING DESTROY IN article_controller.rb TO MAKE USER ABLE TO DELETE SAVED RECORD
  • Go to home/webApps/blog/app/controllers and open articles_controller.rb then add bellow codes bellow (def update ( codes ) end )
  • def destroy
    @article = Article.find(params[:id])
    @article.destroy
    redirect_to articles_path
    end
36. ADDING LINK OF DESTROY IN INDEX PAGE OF ARTICLES AND DEFINING DELETE METHOD TO CONFIRM DELETION.
  • Go to home/webApps/blog/app/views/articles and open index.html.erb and replace the bellow codes with old codes.
  • <h1> Welcome to index page of Articles </h1>
    <table>
    <tr>
    <th>Title</th>
    <th>Text</th>
    <th colspan="2"></th>
    </tr>
    <% @articles.each do |article| %>
    <tr>
    <td><%= article.title %></td>
    <td><%= article.body %></td>
    <td><%= link_to 'Show', article_path(article) %></td>
    <td><%= link_to 'Edit', edit_article_path(article) %></td>
    <td><%= link_to 'Destroy', article_path(article), method: :delete, data: { confirm: 'Are you sure?' } %></td>
    <% end %>
    </tr>

    </table>
    <%= link_to 'New article', new_article_path %>_path %>
  • Note: we need to add just <td><%= link_to 'Destroy', article_path(article), method: :delete, data: { confirm: 'Are you sure?' } %></td> in old code and bellow set of codes combined new codes and old codes to reduce the chances of errors. 









Uploading rails project to web using Git, Bitbucket and Heroku


Tutorial Title: Uploading rails project to web using Github and Heroku

Course: Web Engineering

Instructor: Muhammad Samim


Note: Copy and paste commands in terminal after dollar sign ($)




1. Installing gedit plugins
  • Press Ctrl + Alt + t to open terminal
  • $ sudo apt-get install gedit-plugins
2. Making some changes in gedit to make it more programmers friendly
  • Type gedit in terminal
  • Maximize gedit
  • Click on "Edit"
  • After clicking on "Edit" click on "Preferences"
  • Check "Display line number"
  • Check "Display right margin at column and set it 80
  • Check "Highlight current line"
  • Check "Highlight matching brackets"
  • Click on "Editor tab"
  • Set Tab width: 2 spaces
  • Check "Enable automatic indentation"
  • Click on "Plugins tab"
  • Check "Bracket Completion"
  • Check "Embeded Terminal"
  • Check "File Browser Panel"
  • Check "Multi Edit"
  • Check "Code Comment"
  • Check "Find in Files"
3. Installing Git
  • $ sudo apt-get update
  • $ sudo apt-get install git-core
4. Configuring git (You should have account of github if you don't have then visit https://github.com/ and make an account)
  • git config --global user.name "YOUR USER NAME"
  • git config --global user.email "YOUREMAIL"
     6. go to your project folder > Right click > Open terminal and make sure that your home page is made by you to be displayed on the first screen on heroku if not then follow the steps.
    • rails generate controller Welcome index
    • go to your app directory/app/config/routes
    • now add root 'welcome#index' and save
    • now go to your app directory app/view/welcome/index.html.erb
    • and replace code with
    • <h1> Uploading project on Heroku </h1>
    • and save it
      7. Adding rails project to git ( You must be in project directory)
      • $ git init
      8. Adding all file and changes to git
      • $ git add .
      9. Committing changes files to server
      • $ git commit -m 'initial commit'
      10. Uploading rails project to github.com
      • Go to link https://github.com/
      • Sign in
      • Click on sign + right up 
      • Click on "New repository"
      • Type Repository name
      • Click on "Create"
      • Click on Create repository
      11. Type the following commands (You must be in rails project directory)
      • $ git remote add origin http://github.com/yourUserName/YouRepository.git
      • $ git push -u origin master
      •    Type your user name of github
      •    Type your password 
      •    Enter
      12. Application has been uploaded to GitHub now.
            To check the changes and updates
      • $ git status
      • $ git add -A
      • $ git push origin master
      13. Adding and uploading rails project to Heroku

      14. Add gem file in Gemfile of your project
      • app directory/app/Gemfile
      • copy and paste the following gemfile in the end of line.
      • gem 'rails_12factor', group: :production
      • open your terminal and type $ bundle install
      • Check your ruby version by typing command $ ruby -v
      • your version on terminal after command must be like  ruby 2.3.1 you need to type it like ruby "2.3.1" in your Gemfile of your project
         and save
      15. Deploying your project on Heroku
      16. To use Heroku commands we will install toolbelt. Open your terminal and type the command
      • $ wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
      17. Login your heruko account by your terminal
      • $ heroku login
      • Enter your email
      • Enter your password
      • $ heroku create
      •  
      18. Verifying if remote was added to your project
      • $ git config --list | grep heroku
      19. Deploying the project
      • $ git push heroku master
      20. Migrating your database from your computer to Heroku server
      •  $ heroku run rake db:migrate
      21. Confirming if one dyno is run the web process (Optional)
      • $ heroku ps:scale web=1
      • $ heroku ps
      22. Opening uploaded project online on Heroku
      • $ open heroku
       

      Creating first demo application using scaffold in Ruby on Rails

      Tutorial Title: Creating first demo application using scaffold and rolling back destroying it in Ruby on Rails

      Course: Web Engineering

      Instructor: Muhammad Samim


      Note: Copy and paste commands in terminal after dollar sign ($)


      1. Creating folder for web projects.
      • Press Ctrl + Alt +t to open terminal program
      • $ cd
      • $ mkdir webApps
      • cd webApps
      2. Creating new project
      • $ rails new scaffoldApp -d postgresql
      • $ cd scaffoldApp
      3.  Creating user resource using scaffold
      • $ rails generate scaffold User name:string email:string
      4. Creating database is must if working with PostgreSQL using rake command
      • $ rake db:create
      5. Migrating database using rake to proceed with application
      • $ rake db:migrate
       6. Rollback database in case if done something wrong with it (Optional)
      • $ rake db:rollback
      7. Destroying scaffold
      • $ rails destroy scaffold User
      8. Run rails server to connect with local web server
      • $ rails server
      9.  Showing created scaffold app on browser (rails server must be running)

      10. Click on "New User"

      11.Type your name and email then click on "Create User"

      12. Request successfully accepted and if you want to edit your information click on "Edit"

      • Click on "Back" and enter some entries
      • After entering some entries
      13. Modeling posts
      13.1 Generating posts: we use scaffold command for generating posts model
      • $ rails generate scaffold Post content:text user:references
      13.2 Migrating Post table to the database
      • $ rake db:migrate
      13.3 Validating contents
      • open gedit > file > open > Go to your project folder > app >models and open Post.rb and type the following code.
      • class Post < ActiveRecord::Base
        belongs_to :user
        validates :content, presence: true
        end
      13.4 Associating database entities:
      • Press Ctrl + o to Go to open in gedit click on user.rb modify like following code.
      • class User < ActiveRecord::Base
        has_many :posts
        end
      13.5 Showing Posts on browser
      • Open terminal
      • $ rails server
      • Open browser and type http://localhost:3000/posts



      • Click on "New Post"
      • Type in content and give ID of User table users
      • Click on "Create Post"
      • Click on "Back"
      • Make some posts for User table's users
      • Back to terminal if server is running press Ctrl +c to stop server
      14 Running PostgreSQL to connect and see your database
        • Open terminal
        • $ sudo -u postgres psql
        14.1 Showing your databases
        •  # \l
        •  press q to exit screen of databases to perform next action
        14.2 Connecting to database. (add _development with your database name e.g: FirstApp to FirstApp_development
        • # \c FirstApp_development
        15. Query for showing contents of database
        •  # SELECT * from Users;
        •  press q to exit screen of databases to perform next action
        • # SELECT * from Posts;
        15.1 exiting from database
        • # \q
        16. Working in Rails console.
        • $ rails console
        • > u = User.find(1)
        • > u.posts
        • > u = User.first
        • > u = User.all
        • > u[0]
        • > u[1]
        • > u[2]
        • > u[3]
        • > u[0].posts
        • > u[1].posts
        • > u[2].posts
        • > u[3].posts
        16.1 Creating, Reading, Updating and Deleting operations in rails console

        16.2 Creating: New recored will be created
        • $ rails console
        • > u = User.new
        • > u.name = "Muhammad Samim"
        • > u.email = "muhammadsamim2016@gmail.com"
        • > u.save
        16.2 Reading: Record 1 will be showed
        • > User.find(1)
        16.3 Updating: Record 2 will be modified
        • > u = User.find(2)
        • > u.name = "Herry"
        • > u.email = "herry@email.com"
        16.3 Deleting: reading 4 will be deleted
        • > u = User.find(5)
        • > u.destroy

        Installing Ruby on Rails on Ubuntu 16.04 LTS

        Tutorial Title: Installing Ruby on Rails on Ubuntu 16.04 LTS

        Course: Web Engineering

        Instructor: Muhammad Samim

        Note: Copy and paste commands in terminal after dollar sign ($)


        1. Selecting best server for updating OS
        • Search "Software & Update" and Open
        • .Click on mentioned drop down button and click on others
        • Find Japan in list and click on small mentioned icon
        • Click on "ubuntutym.u-toyama.ac.jp"
        • Click on "Choose Server"
        • Type your computer password and Click on "Authenticate"
        • Search "Software Updater" and open it.
        •  
        • Click on "Install Now"
        • You OS will be updated


        2. Installing dependencies for Ruby Note: Type or copy and paste commands after $
        • Search "Terminal" and open or press Ctrl + Alt + t
        • $ sudo apt-get update
        • $ sudo apt-get upgrade
        • $ sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev
        • $ sudo apt-get install sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
        3. Installing rbenv Note: Type or copy and paste commands after $
        • $ cd
        • $ git clone git://github.com/sstephenson/rbenv.git .rbenv
        • $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
        • $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
        • $ exec $SHELL
        4. Building Ruby Note: Type or copy and paste commands after $
        • $ git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
        • $ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
        • $ exec $SHELL 
        5. Installing Ruby Note: Type or copy and paste commands after $
        • $ rbenv install 2.3.1
        • $ rbenv global 2.3.1
        • $ ruby -v
         6. Installing Bundler Note: Type or copy and paste commands after $
        • $ echo "gem: --no-ri --no-rdoc" > ~/.gemrc
        • $ gem install bundler
        7.  Configuring Git, Bitbucket/Github and Heroku

        7.  Installing Rails Note: Type or copy and paste commands after $
        • $ sudo apt-get install -y nodejs
        • $ gem install rails -v 4.2.6
        • $ rbenv rehash
        • $ rails -v
        8. Confirming successful installation of Ruby and Rails Note: Type or copy and paste commands after $
        • for ruby type $ ruby -v
        • for rails type $ rails -v
        9. Installing and configuring PostgesSQL Note: Type or copy and paste commands after $
        • $ sudo apt-get install postgresql-common
        • $ sudo apt-get install postgresql-9.5 libpq-dev
        • apt-get -y install postgresql postgresql-contrib libpq-dev
        10. Creating user name with your current user name of computer Note: Type or copy and paste commands after $
        • $ sudo -u postgres createuser yourname -s
        11. Creating password for created user Note: Type or copy and paste commands after $
        • $ sudo -u postgres psql
        • \password
        • yourpassword


        12. Installing MySQL (Its Choice to use it or postgreSQL, Not recommended) Note: Type or copy and paste commands after $$
        • $ sudo apt-get install mysql-server mysql-client libmysqlclient-dev

        Installing Ubuntu 16.04 with Microsoft Windows 10 dual boot

        Tutorial Title: Installing Ubuntu 16.04 (LTS) with Microsoft Windows 10 dual boot

        Instructor: Muhammad Samim



        1. Download Ubuntu 16.04 (LTS) from bellow link for 64 bit OS (You can download 32 bit OS too)
        2. http://www.ubuntu.com/download/desktop/thank-you?country=PK&version=16.04.1&architecture=amd64
        3. Download Universal Installer to make your flash disk bootable from bellow link
        4. http://www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/
        5. Run it and follow the steps or click on bellow link for making bootable Ubuntu flash disk
        6. http://insidewebe.blogspot.com/2016/08/how-to-make-linix-ubuntu-bootable-flash.html
        7. Right click on "This PC"
        8. Click on "Manage"
        9. Click on "Disk Management"
        10. Right click on any drive to shrink at least 50 GB spcace should be available
        11. Click on shrink
        12. Set 50000 MB (Note: 50000 MB space should be available on drive)
        13. Click on "Shrink"
        14. Unallocatted drive will be created leave it as it is
        15. Open "Control Panel"
        16. Click on "Category"
        17. Click on "Small Icons"
        18. Click on click "Power Management"
        19. Click on "Choose what the power button does"
        20. Click on "Change settings that are currently unavailable"
        21. Uncheck (Make empty) "Turn on fast startup (recommended)"
        22. Plug your bootable ubuntu flash disk with your computer
        23. Restart you computer
        24. Press F12 or F10 or F1 key to go to boot menu
        25. Select Flash Drive and Enter
        26. Click on "Install"
        27. Select any Language
        28. Click on "Continue"
        29. Click on "Something else"
        30. Click on Unallocated Partition to select 
        31. Click on + sign
        32. Click on drop down button
        33. Select Swap
        34. Click on Logical 
        35. Set Space for swap (8000 MB)
        36. Click on + sign again
        37. Click on drop down button
        38. Select "Ext4 Journaling File System"
        39. Click on Primary
        40. Click on Mount
        41. Select " \ "
        42. Click on "Install Now"
        43. Click on "Continue"
        44. Click on "Continue"
        45. Select keyboard layout
        46. Click on "Continue"
        47. Type Name
        48. Type Computer Name (Computer name should be short)
        49. Set Password
        50. Click on "Continue"
        51. File copying will be done
        52. Click on "Restart Now"