Monday, 16 December 2019

How to sort the array of string by alphabetical order with domain based components in ruby?


Input:

array = ["analytics.ramo.com", "ccc.ramo.com", "ccc.test.ramo", "ddd.kumar.ramo.com", "ec2.new.ramo.com", "ramo.com", "test-new.ramo.com", "top-test.ramo.com"] 

Solution:

array.sort_by do |domain|
  parts = domain.split('.').reverse
  parts.unshift(parts.count)
end


Output:

["ramo.com",
 "analytics.ramo.com",
 "ccc.ramo.com",
 "test-new.ramo.com",
 "top-test.ramo.com",
 "ccc.test.ramo",
 "ddd.kumar.ramo.com",
 "ec2.new.ramo.com"]

Monday, 4 November 2019

How to use module as Namespace in ruby?

 Module or Mix-in used as a Namespace in ruby. It is used to avoid collision between two classes.


module Rajkumar
    class Uthayaa
        attr_accessor :email

        def display_email
            puts "my email is #{@email}"
        end
    end
end

module Somu
    class Uthayaa
        attr_accessor :email

        def display_email
            puts "my email 2 is #{@email}"
        end
    end
end

puts raj = Rajkumar::Uthayaa.new
puts raj.email='rajutaya@gmail.com'
puts raj.display_email
puts raj = Somu::Uthayaa.new
puts raj.email='lalalslsls@gmail.com'
puts raj.display_email

How Database index is functioning?


Indexing is a way to optimize the performance of a database by minimizing the number of disk accesses required when a query is processed. It is a data structure technique which is used to quickly locate and access the data in a database.

Indexes are created using a few database columns.
  1. The first column is the Search key that contains a copy of the primary key or candidate key of the table. These values are stored in sorted order so that the corresponding data can be accessed quickly.
  2. Note: The data may or may not be stored in sorted order.
  3. The second column is the Data Reference or Pointer which contains a set of pointers holding the address of the disk block where that particular key value can be found.


Sunday, 3 November 2019

How to install skype on ubuntu 16.04


Kindly run the below commands in terminal for skype installation.

1. Add skype linux repository in your system.

   $ echo "deb [arch=amd64] https://repo.skype.com/deb stable main" | sudo tee /etc/apt/sources.list.d/skype-stable.list

2. To fetch and install Skype public key so that APT package manager verify from repository.

   $ wget https://repo.skype.com/data/SKYPE-GPG-KEY
$ sudo apt-key add SKYPE-GPG-KEY

3. To use https
$ sudo apt install apt-transport-https

4. Update the software source and install skype
$ sudo apt update
 $ sudo apt install skypeforlinux

5. Once installed type skypeforlinux in your application. You can use your skype.

Friday, 11 October 2019

What is difference between display:none & visibility:hidden in CSS?

In CSS display:none & visibility:hidden are mainly used for hiding the tags.


display:none tags will not appear in page at all.

There will be no space allotted in between other tags. Although you can interact with it through DOM.

rajkumar | <p style="display:none;">Style in this tag</p> | rajkumar

OUTPUT for display:none:

rajkumar |  | rajkumar


visibility:hidden tags will not visible.

There will be space allotted in between other tags.

rajkumar | <p style="visibility:hidden;">Style in this tag</p> | rajkumar

OUTPUT for visibility:hidden

rajkumar |                                  | rajkumar. 

Friday, 27 September 2019

Email template design with table cell

Implemented the Email templates with table cell. It will support for all the mailing communications.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
</head>
<body style="margin: 0; padding: 0;font-family: 'Montserrat', sans-serif;background-color: #069C90">
<table cellspacing="0" width="100%" style="padding: 20px 40px;">
    <tr align="center" bgcolor="#069C90">
        <td style="font-size: 30px;color:#fff;font-weight: bold;">
            Hello
        </td>
    </tr>
    <tr align="center" bgcolor="#069C90">
        <td style="font-size: 30px;color:#fff;font-weight: bold;font-style: italic;padding-bottom: 15px;">
            testing
        </td>
    </tr>
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr bgcolor="#f1f1f1">
                    <td style="padding: 10px;color: #6A6A6A;font-size: 20px;" align="center">
                        Thank you for choosing <b style="color: #069C90;font-size: 25px;">testing.</b>
                    </td>
                </tr>
                <tr bgcolor="#f1f1f1">
                    <td style="padding: 10px;color: #6A6A6A;font-size: 20px;" align="center">
                        Finding your new home is our responsibility.
                    </td>
                </tr>
                <tr bgcolor="#f1f1f1">
                    <td style="padding: 10px;color: #6A6A6A;font-size: 20px;" align="center">
                        We wish to full-fill your dream of buying a property at the best price.
                    </td>
                </tr>
                <tr bgcolor="#f1f1f1">
                    <td style="padding: 10px;color: #6A6A6A;font-size: 20px;" align="center">
                        Your hunt for home ends here.
                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td>
                        <table border="0" cellpadding="0" cellspacing="0" width="100%">
                            <tr>
                                <td>
                                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                                        <tr style="border-bottom-left-radius: 10px">
                                        <td width="50%">
                                            <img src="img/image_1.jpg" alt="" width="100%" height="auto" style="display: block;" />
                                        </td>
                                        <td width="50%" bgcolor="#f1f1f1">

                                            <a href="#" style="color: #fff;top: 40%;border-radius: 5px;font-weight: bold;font-size: 20px;right: 23%;padding: 20px;background-color: #FF5984;text-decoration: none;">testing</a>

                                        </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>

                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td style="padding: 10px;font-weight: bold;color: #069C90;font-size: 25px;" align="center">
                        More reason to choose from test
                    </td>
                </tr>
               
                <tr bgcolor="#fff">
                    <td style="padding: 10px;font-weight: bold;color: #069C90;font-size: 25px;" align="center">
                        Refer & Earn
                    </td>
                </tr>
                <tr>
                    <td>
                        <table border="0" cellpadding="0" cellspacing="10" width="100%" bgcolor="#E0F3F2">
                            <tr>
                                <td width="50%" align="center" style="border-right: 1px solid #069C90;" bgcolor="#E0F3F2">
                                    <img src="img/image_6.png" height="auto"/>
                                </td>
                                <td width="50%" align="center">
                                    <table border="0" cellpadding="0" cellspacing="10" width="100%">
                                        <tr>
                                            <td style="color: #5B5B5B;font-weight: bold;font-size: 20px;padding: 10px;" align="center">Refer your Friend's to find a property<br>
                                                in rajutaya.blogspot.com</td>
                                        </tr>
                                        <tr style="color: #069C90;font-size: 20px;" align="center">
                                            <td>Maximum <strong style="font-size: 30px;">₹50,000</strong></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td style="padding: 10px;font-weight: normal;font-style:italic;color: #6A6A6A;font-size: 25px;" align="center">
                        Check out these homes!, which are similar to other<br>
                        listings you've viewed
                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td style="padding: 10px;" align="center">
                        <a href="#" style="text-decoration: none;display: inline-block;padding: 20px;background-color:#FF4576;border-radius: 5px;text-transform: uppercase;color: #fff;font-weight: bold;">Your Dream Home</a>
                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td style="padding: 10px;font-weight: bold;color: #6C6C6C;font-size: 30px;font-style: italic;font-weight: normal" align="center">
                        <strong style="color:#069C90;">1000+</strong> happy customer booked their
                        homes through us
                    </td>
                </tr>
                <tr bgcolor="#fff">
                    <td style="padding: 10px;" align="center">
                        <img src="/img/image_7.png" width="100%" height="auto">
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table align="center" border="0" cellpadding="0" cellspacing="10" width="100%" style="font-size: 25px;" bgcolor="#069C90">
                <tr align="center" style="color: #fff;">
                    <td style="border-right: 1px solid #fff">Chennai</td>
                    <td style="border-right: 1px solid #fff">Bangalore</td>
                    <td style="border-right: 1px solid #fff">Mumbai</td>
                    <td style="border-right: 1px solid #fff">Kolkata</td>
                    <td>Hyderabad</td>
                </tr>
            </table>
        </td>

    </tr>
</table>

</body>
</html>

Saturday, 7 September 2019

Type of Ajax calling

Ajax calling with manual passing the data

<form id='user_info'>
    <input type='text' id='user_id' value='40'>
    <input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>

 
<script type='text/javascript'>
function get_user_info(){
    user_id = $('#user_id').val();
    project_id = $('#project_id').val();
    $.ajax({
    url: '/create_user_information',
    data: {user_id: user_id, project_id: project_id},
    dataType: 'script',
    type: 'POST',
    success: function (data) {
    }
  });
}

</script>


Ajax calling with serialize method

<form id='user_info'>
    <input type='text' id='user_id' value='40'>
     <input type='text' id='project_id' value='402'>
<a href='javascript:void(0)' onclick='get_user_info()'></a>
</form>


<script type='text/javascript'>
function get_user_info(){
    user_id = $('#user_id').val();
    project_id = $('#project_id').val();
    $.ajax({
    url: $('#user_info').attr('action'),
    data: $('#user_info').serialize(),
    dataType: 'script',
    type: 'POST',
    success: function (data) {
    }
  });
}

</script>

Interactor in Rails

What is interactor? Interactor provides a common interface for performing complex user interactions An interactor is a simple, sin...