Thursday 29 March 2018

Pattern Program using C


#include <stdio.h>
int main()
{
   int i,j,k,m,space, rows;
   scanf("%d\n",&rows);
   for(i=0; i<=rows; i++)
   {
       for(space=0; space<=rows-i; ++space)
       {
           printf("  ");
       }
       for(j=i;j>=0;j--)
       {
           printf("%d ",j);
           m=j;
           if(m==0)
           {
               for(k=1;k<=i;k++)
               {
                   printf("%d ",k);
               }
           }
       }
       printf("\n");
   }
   return 0;
}

Output:  

Wednesday 28 March 2018

Calculate age using datepicker


$( function() {
    $( "#datepicker").datepicker({dateFormat: 'mm/dd/yyyy'});
  } );
$("#datepicker").datepicker({
        maxDate: '+0d',    
        yearRange: '1914:3025',
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true,
      
    }).on('change', function () {
        var age = getAge(this);
        $("#age").html("You are " + age + " old");
      
    });

    function getAge(dateVal) {
        var
            birthday = new Date(dateVal.value),
            today = new Date(),
            ageInMilliseconds = new Date(today - birthday),
            years = ageInMilliseconds / (24 * 60 * 60 * 1000 * 365.25 ),
            months = 12 * (years % 1),
            days = Math.floor(30 * (months % 1));
            return Math.floor(years) + ' years ' + Math.floor(months) + ' months ' + days + ' days';
    }

Friday 23 March 2018

Few Questions - Answers

1.       What is the result of NaN = = NaN?
 Answer:-  false.
- NaN stands for Not a Number.
- suppose there is a NaN as x and another NaN is y. value of both can be different.
2.       $("#a1").on("click",{times: 3},function_call);
Answer: -  Answer would be  function_call  will be executed once regardless of the number of times a1 is clicked.

3.       Mention one advantage of using $.ajax over $.get or $.post?
Answer: -  $.ajax offers error callback option

4.       What will following code do?
code:  $(“div#first , div.first , ol#items > [name$=’first’] “)
Answer:  
div#first - will select div having id as first
div.first - will select div having class as first
ol#items > [name$=’first’] “) – will select immediate child of ordered list having id as items whose name ends with ‘first’

Wednesday 21 March 2018

HOW TO KNOW WHICH EVENTS ARE TRIGGERED ON SCROLL OR MOUSE EVENTS

monitorEvents(document.body); // logs all events on the body

monitorEvents(document.body, 'mouse'); // logs mouse events on the body

monitorEvents(document.body.querySelectorAll('input')); // logs all events on inputs

Tuesday 20 March 2018

HOW TO HOLD $(DOCUMENT).READY(FUNCTION{}); TO BE RUN

Use $.holdReady(true); before or after  $(document).ready(function{});

Thank you

SOLUTION OF ERROR IN PHP: CANNOT MODIFY HEADER INFORMATION – HEADERS ALREADY SENT BY..

Hello,
to solve this error, you have to check following things
  1. session_start(); should be at the first position in your program
  2. dont put blank space or white space before “<?php “
Thank you

DISPLAY ALERT WHEN FOOTER DIV IS DISPLAYED

<!doctype html>
<html lang="en">
    <head>
        <title>Footer display</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script>
            $(document).ready(function() {
                $(window).scroll(function() {
                    console.log("window scrolltop: "+$(window).scrollTop());
                    console.log("Footer height: "+$('.footer').offset().top);
                    console.log("Window height: "+$(window).height());
                    if ($(window).height() >= ( $('.footer').offset().top - $(window).scrollTop()  )) {
                        console.log('Footer reached!');
                    }
                });
            });   
        </script>
        <style>
            body { margin: 0; }
        </style>
    </head>
    <body style="padding:10px;padding-bottom:0px;">
        <div>
            <p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p>

            <p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p>

            <p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p>

            <p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p>

            <p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p><p>p</p>
        </div>
        <div class="footer">
            <h1 style="background-color:pink;">
                Footer
            </h1>
        </div>
    </body>
</html>

Infinite scroll on collection page in Shopify

 Hello, Collection page structure is as followed {% paginate collection.products by 48 %} <div class="collection-content"> ...