Posts

Memory Leaks in ReactJs

Image
Memory leak can be understand like program engaging memory for unused data. Data is stored in memory but not used by and program. memory leak warning React developer can understand by these given examples likes: 1. DOM Event Listener Let's suppose we define any event handler on component mount but forgot to define remove event listener  on component unmount. When component unmount this listener still present in memory but as unused handler.  So it is recommended to always define remove event listener on component unmount or clean up callback. see the below code sample for an idea. const MyComponent = () => {                             useEffect (() => {                                 const handleClick = () => {                                   //do something when we click      

Leap Year Calculator

Image
We know any year that is evenly divisible by 4 is a leap year : for example, 1988, 1992, and 1996 are leap years.  However, there is still a small error that must be accounted for. To eliminate this error, the Gregorian calendar stipulates that a year that is evenly divisible by 100 (for example, 1900) is a leap year only if it is also evenly divisible by 400.  For this reason, the following years are not leap years: 1700, 1800, 1900, 2100, 2200, 2300, 2500, 2600 This is because they are evenly divisible by 100 but not by 400.  The following years are leap years: 1600, 2000, 2400 This is because they are evenly divisible by both 100 and 400.  How to determine whether a year is a leap year To determine whether a year is a leap year, follow these steps: If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. If the year is evenly divisible by 400, go to step 4. Ot

ssl error in chrome, firefox and other browsers

Image
Hey Guys, If you are continuously getting ssl error issue during browsing with your regulaar websites like, facebook.com gmail.com yahoo.com etc etc then might be your antivirus making some issue. I am using ESET Smart Security 5 and i am also getting this ssl errorin all my browser... so i have setup this setting to overcome this issue. follow the step given below and resolve this issue : 1. Start ESET Smart Security 5 2. Click on Setup 3. Then click on Web and Email 4. Click on " Configure " 5. Expand " Web and Email " --> " Protocol Filtering " --> " SSL " --> 6. Choose " Do not scan SSL Protocols " and click " OK " button. View Fig 1 as shown below: Fig 1 - Resolve SSL Error Issue That's It, You Resolved the Issue...!!!

Check Chrome and Safari using jQuery

Use the following code: var userAgent = navigator . userAgent . toLowerCase (); $ . browser . chrome = /chrome/ . test ( navigator . userAgent . toLowerCase ()); // Is this a version of Chrome? if ( $ . browser . chrome ){ userAgent = userAgent . substring ( userAgent . indexOf ( 'chrome/' ) + 7 ); userAgent = userAgent . substring ( 0 , userAgent . indexOf ( '.' )); $ . browser . version = userAgent ; alert ( 'chrome' ); // If it is chrome then jQuery thinks it's safari so we have to tell it it isn't $ . browser . safari = false ; } // Is this a version of Safari? if ( $ . browser . safari ){ userAgent = userAgent . substring ( userAgent . indexOf ( 'safari/' ) + 7 ); userAgent = userAgent . substring ( 0 , userAgent . indexOf ( '.' )); $ . browser . version = userAgent ; alert ( 'safari' );

How to modify xml data using php - Part 2

Use the following code to update the submitted value from modify.php into xml: <?php function  update_book_id ( $id ,   $filename   =   'loaned.xml' ) { $data   =  simplexml_load_file ( $filename ); for ( $i   =   0 ,   $length   =  count ( $data -> resource -> book );   $i   <   $length ;   $i ++)      {      if ( $data -> resource -> book [ $i ]-> ID  ==   $id )          {                  $btitle   =   $_POST [ 'btitle' ];                   $bdate   =   $_POST [ 'bdate' ];          $bookrentdate   =   $_POST [ 'bookrentdate' ];          $booksid   =   $_POST [ 'booksid' ];                  $data -> resource -> book [ $i ]-> title  =   $btitle ;          $data -> resource -> book [ $i ]-> date  =   $bdate ;          $data -> resource -> book [ $i ]-> retdate  =   $bookrentdate ;          $data -> resource -> book [ $i ]-> SID  =   $booksid ;          break ;          }      }     file_

How to modify xml data using php - Part 1

In modify.php add the following code: <?php $modifybook = $_GET [ 'bid' ]; $doc = new DOMDocument (); $doc -> load ( 'loaned.xml' );   $booklist = $doc -> getElementsByTagName ( "book" ); foreach ( $booklist as $book ) { $bookids = $book -> getElementsByTagName ( "ID" ); $bookid = $bookids -> item ( 0 )-> nodeValue ; if ( $bookid == $modifybook ){       $booktitles = $book -> getElementsByTagName ( "title" );       $booktitle = $booktitles -> item ( 0 )-> nodeValue ;       $dates = $book -> getElementsByTagName ( "date" );       $date = $dates -> item ( 0 )-> nodeValue ;             $retdates = $book -> getElementsByTagName ( "retdate" );       $retdate = $retdates -> item ( 0 )-> nodeValue ;             $sids = $book -> getElementsByTagName ( "SID" );       $sid = $sids -> item ( 0 )-> nodeValue ;       echo