Search This Blog

Sunday, August 25, 2013

About Me




Arun Gopinathan

Age: 24
Lives in: Arlington, TX
Education: B.Tech (IT),  MS (Computer Science) [Currently Studying]
Post Graduate Institution : University of Texas at Arlington
Under graduate Institution: RMK Engineering College, (Affliated to Anna University)
Handed: Ambidextrous
Sun Sign: Cancer
Interests : Computers, Programming, Rubiks Cubing, Blogging

About Me

I'm a Computer Enthusiast who fell in love with Computers when I was in my 3rd Grade, from then my interest on Computers in increasing day by day. I love solving problems using computers.

I have worked in Linux, Windows and Mainframes, would love to work with MAC as well.

I hold a honors degree of Bachelor of Technology (B.TECH) in Information Technology(IT).

I worked as Systems Engineer in TATA Consultancy Services for 3 years. I have worked on developing Web Applications in AngularJS, HTML5, SASS, Bootstrap and also have worked in an ASP.NET web and web services development project. I have also worked on technologies like PHP, Java, JSP, Servlets, WordPress, DOJO, Web Sphere Integration Developer (WID), Rational Application Developer (RAD), ILOG JRules and more. If you would like to get more details on the projects i have worked on, please see my linkedin profile (link given below)

I'm currently studying Master of Sciene (MS) in Computer Science (CS) in University of Texas at Arlington.

In my free time you can find me competing in Programming contests hosting sites like TopCoder, Hacker Rank, Code Forces etc, I invest some of my time to try new technologies and I also love to write in this blog.

Quick Links

Top Coder Profile - Arun.G
Linked In Profile - Arun Gopinathan
GitHub Profile - ArunGopinathan
Hacker Rank Profile - Arun_G

Saturday, August 17, 2013

Setup WordPress in Local Machine

Word Press Local Setup


WordPress is a very popular Content Management System(CMS) used by blogging sites around the world. Its architecture allows to add plug-ins and widgets, so we can build a customized plug-in / widget and add it to WordPress site that is already hosted.
To develop Plug-ins/ widgets we first need to set WordPress in our local machine since it would be difficult to test the plug-ins/ widgets in live environment all the time.
WordPress is built using PHP and MySQL so first you need to install PHP& MySQL.

WordPress Setup Instructions:
i)                    First Download XAMPP and Install it. It is free and it installs PHP, MySQL and Apache Web Server and configures it for you.
ii)                   To check if everything is working open "XAMPP Control Panel" in your machine and click on start for Apache and MySQL.
 iii)                    Open a Web Browser and enter “localhost” if the XAMPP Page opens, XAMPP is successfully installed.
 iv)                   Next you need to download the latest version of Word Press. Go to http://wordpress.org/download/ and download WordPress.

v)                    Extract the zip file and place in the “<XAMPP INSTALLATION PATH>\XAMPP \htdocs” folder.
 vi)                    Next you need to create a database to install WordPress. Open "PhpMyAdmin" by going to http://localhost/phpmyadmin/ or click on PhpMyAdmin in the XAMPP Page 
vii)           In PhpMyAdmin click on Databases and create a new database ‘wp_wordpress’

viii)                  Go to XAMPP\htdocs\wordpress folder and open ‘wp-config-sample.php’ and edit it. Change the ‘database_name_here’ to database name created in above step ‘db_wordpress’. The default user name and password for MySQL is ‘root’ and empty password. So change the ‘username_here’ to ‘root’ and ‘password_here’ to ‘’. [Note: Don't use default username and password when you are hosting the site].
ix)                     Save the file and rename it from ‘wp-config-sample.php’ to ‘wp-config.php’.

x)            Now open http://localhost/wordpress/wp-admin/install.php in web browser

xi)           Fill the Site Title, Username, password, twice and email and click on Install Wordpress
xii)          WordPress will be installed and success message will be displayed.

xiii)                 Now you can go to the admin page by going to http://localhost/wordpress/wp-admin/ , it has settings for administrator to customize the site like changing the theme, add plug-ins, widgets etc.

xiv)               You can go to the blog site by going to “localhost/wordpress”


You have now successfully configured WordPress in local machine.

Coding Bat Java Array-1 solutions 15 to 27


This post contains the solutions to Java Array-1 section of codingbat.com for problems 15 to 27. If you are new here, you can check my previous post learn-coding-computer-programming-for-beginners.Solutions to previous sections are also available check the links to java-warmup-1 , java-warmup-2, java-string1. Solutions to problems 1 to 14 are available in java-array-1.


15.       Problem Name : double23 
Solution:
Hint: Given an int array, return true if the array contains 2 twice, or 3 twice
Constraint: The array will be length 0, 1, or 2. .

       public boolean double23(int[] nums)
       {
                if(nums.length>1)
                {
                       return((nums[0]==2 && nums[1]==2)||(nums[0]==3&&nums[1]==3));
                }
                else
                       return false;
       }


16.       Problem Name : fix23 
Solution:
Hint: Given an int array length 3, if there is a 2 in the array immediately followed by a 3, set the 3 element to 0. Return the changed array. 
       public int[] fix23(int[] nums)
       {
                for(int i=0;i<nums.length-1;i++)
                {
                       if(nums[i]==2 && nums[i+1]==3)
                       {
                       nums[i+1]=0;
                       break;
                       }
                }
                return nums;        
       }


17.       Problem Name : start1 
Solution:
Hint: Start with 2 int arrays, a and b, of any length. Return how many of the arrays have 1 as their first element. 
       public int start1(int[] a, int[] b)
       {     
              int count=0;
                if(a.length>=1)
                {
                 if(a[0]==1)
                        count++;
                }
                if(b.length>=1)
                {
                       if(b[0]==1)
                             count++;
                }
                return count;
       }
18.       Problem Name : biggerTwo 
Solution:
Hint: Start with 2 int arrays, a and b, each length 2. Consider the sum of the values in each array. Return the array which has the largest sum
Constraint:  In event of a tie, return a. 
       public int[] biggerTwo(int[] a, int[] b)
       {
                if((a[0]+a[1])>=b[0]+b[1])
                       return a;
                else
                       return b;
       }

19.       Problem Name : makeMiddle 
Solution:
Hint: Given an array of ints of even length, return a new array length 2 containing the middle two elements from the original array.
Constraint: The original array will be length 2 or more. 
       public int[] makeMiddle(int[] nums)
       {
              int[] a = new int[2];
                if(nums.length>1)
                {
                       a[1]=nums[nums.length/2];
                       a[0]=nums[nums.length/2-1];
               
                       return a;
                }
                else
                       return nums;
       }


20.       Problem Name : plusTwo 
Solution:
Hint: Given 2 int arrays, each length 2, return a new array length 4 containing all their elements. 
       public int[] plusTwo(int[] a, int[] b)
       {
                int[] c = new int[a.length+b.length] ;
               
                c[0]=a[0];
                c[1]=a[1];
               
                c[2]=b[0];
                c[3]=b[1];
                      
       return c;
       }


21.       Problem Name : swapEnds 
Solution:
Hint: Given an array of ints, swap the first and last elements in the array. Return the modified array.
Constraint: The array length will be at least 1.
       public int[] swapEnds(int[] nums)
       {
                int tmp;
               
                tmp=nums[0];
                nums[0]=nums[nums.length-1];
                nums[nums.length-1]=tmp; 
               
                return nums;
       }
22.       Problem Name : midThree 
Solution:
Hint: Given an array of ints of odd length, return a new array length 3 containing the elements from the middle of the array.
Constraint: The array length will be at least 3. 
       public int[] midThree(int[] nums)
       {
                int[] a = new int[3];
                int middle=nums.length/2;
                a[0]=nums[middle-1];
                a[1]=nums[middle];
                a[2]=nums[middle+1];
             
                return a;
                
       }

23.       Problem Name : maxTriple 
Solution:
Hint: Given an array of ints of odd length, look at the first, last, and middle values in the array and return the largest
       public int maxTriple(int[] nums)
       {
              int max=0;
                if(nums.length>1)
                {
                      max=nums[0]>nums[nums.length-1]?nums[0]:nums[nums.length-1];
                      max=max>nums[nums.length/2]?max:nums[nums.length/2];
                }
                return max;
       }

24.       Problem Name : frontPiece 
Solution:
Hint: Given an int array of any length, return a new array of its first 2 elements. If the array is smaller than length 2, use whatever elements are present. 
       public int[] frontPiece(int[] nums)
       {
                if(nums.length>1)
                {
                  int[] a = new int[2];
                     a[0]=nums[0];a[1]=nums[1];
                
                     return a;
                }
                else if(nums.length==1)
                {
                     int[] b = new int[1];
                     b[0]=nums[0];
               
                     return b;
                }
                else
                {
                      int[] c=new int[0];
                    
                      return c;
                }
       }

25.       Problem Name : unlucky1
Solution:
Hint: We'll say that a 1 immediately followed by a 3 in an array is an "unlucky" 1. Return true if the given array contains an unlucky 1 in the first 2 or last 2 positions in the array. 
       public boolean unlucky1(int[] nums)
       {
                int i=0;
                if(nums.length>2)
                {
               
                       if(
                                    (nums[0]==1 && nums[1]==3)||
                                    (nums[1]==1 && nums[2]==3)||
                                    (nums[nums.length-1]==3 &&nums[nums.length-2]==1)||
                                    (nums[nums.length-2]==1 && nums[nums.length-3]==3)
                           )
                             return true;
                       else
                             return false;
                }
                else if(nums.length==2)
                {
                       if(nums[0]==1 && nums[1]==3)
                             return true;
                       else
                             return false;
                }
                else

                return false;
       }

26.       Problem Name : make2 
Solution:
Hint: Given 2 int arrays, a and b, return a new array length 2 containing, as much as will fit, the elements from a followed by the elements from b.
Constraint: The arrays may be any length, including 0, but there will be 2 or more elements available between the 2 arrays. 
public int[] make2(int[] a, int[] b)
       {
              int [] empty=new int[0];
              int i=0;
              if(a.length!=0 && b.length!=0)
              {
                 if((a.length<b.length) &&(a.length!=0 && b.length!=0))
                  {
                   int[] c=new int[2];
                   for(i=0;i<a.length;i++)
                    {
                     c[i]=a[i];
                    }
                    if(c[1]==0)
                       c[1]=b[0];
                 return c;
                  }
                  else
                  {
                   int[] arr1=new int[2];
                    for(i=0;i<b.length;i++)
                    {
                    arr1[i]=a[i];
                    }
                    if(arr1[1]==0)
                       arr1[1]=b[0];
                    return arr1;
                  }
              }
              else
              {
                     if(a.length==0)
                     return b;
                     if(b.length==0)
                     {
                           int[] arr2=new int[2];
                           for(i=0;i<2;i++)
                                  arr2[i]=a[i];

                           return arr2;
                     }
              return empty;
              }
       }

27.       Problem Name : front11 
Solution:
Hint: Given 2 int arrays, a and b, of any length, return a new array with the first element of each array. If either array is length 0, ignore that array. 
       public int[] front11(int[] a, int[] b)
       {
                int[] twoarray=new int[2];
                int[] onearray=new int[1];
                int[] zeroarray=new int[0];

                if(a.length>0 && b.length>0)
                {
                       twoarray[0]=a[0];
                       twoarray[1]=b[0];
                       return twoarray;
                }
                else
                {
                if(a.length>0)
                       onearray[0]=a[0];
                if(b.length>0)
                       onearray[0]=b[0];
                if(a.length>0 || b.length>0)
                       return onearray;
                else
                       return zeroarray;
                }
                         
       }


Please check my posts for solutions to other sections of codingbat.com.

Labels