Tuesday, 7 February 2012

How to check two dates in javascript?

Hi Folks,

      /* Getting current year */
    var current_date = new Date();
      /* Converting user input date of birth to javascript data format... */
      var date_of_birth = new Date($('#order_date_of_birth_year').val(),$('#order_date_of_birth_month').val()-1,$('#order_date_of_birth_day').val());
      if(date_of_birth.getTime()>current_date.getTime()) {
        $('#date_of_birth_error').html("Date of Birth cannot be a future date");
        err = err+1;
        return false;
      }else {
          $('#date_of_birth_error').html(" ");
      }

Cheers!

Friday, 13 January 2012

How to delete files periodically usign cron.

Hi All,

Please use the following line to delete files:

find /var/www/archive/dbbackup/ -type f -name '*.sql.gz' -mtime +1 -exec rm {} \;

-mtime +1 means all files older more then 1 day.

Thanks
Cheers!

Friday, 30 December 2011

How to add Google Map on your page?

 Hi Guys!

Plesae put following lines on your page to add google map:



<!DOCTYPE html>
<html>
  <head>
    <title>Google Maps JavaScript API v3 Example: Map Simple</title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta charset="UTF-8">
    <style type="text/css">
      html, body, #map_canvas {
        margin: 0;
        padding: 0;
    width: 400px;
        height: 400px;
      }
    </style>
    <script type="text/javascript"
        src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

    <script type="text/javascript">
      var map;
      function initialize() {
        var myOptions = {
          zoom: 18,
          center: new google.maps.LatLng(-34.397, 150.644),
          mapTypeId: google.maps.MapTypeId.TERRAIN
        };
        map = new google.maps.Map(document.getElementById('map_canvas'),
            myOptions);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map_canvas"></div>
  </body>
</html>

Cheers!

Monday, 19 December 2011

How to send array from action to template in symfony?


Suppose we have testArray given following:

$this->testArray = array('ashwani', 'bablu','cintu');
$myArray = $sf_data->getRaw('testArray');
print_r($myArray);

Output will be in template file:

Array
(
    [0] => 'ashwani'
    [1] => 'bablu'
    [3] => 'chintu'
)


Cheers!

Thursday, 15 December 2011

How to generate Module in symfony?

$ php symfony doctrine:generate-module frontend organizer EventOrganizer

this will generate template with tr td format.

OR

$ php symfony doctrine:generate-module  --with-show --non-verbose-templates frontend organizer EventOrganizer

this will generate template with echo $form format.




here organizer is a module name and EventOrganizer is table name defined in schema.yml


Cheers!

Thursday, 13 October 2011

How to find text recursively in file using linux commad?

Folks,

Please use the following command:

find <folderpath> -type f | xargs grep -l "131848637983654"

Here "131848637983654" has to find in <folderpath>

Cheers!

Monday, 3 October 2011

How to use symfony inbuild functions in non-symfony class in lib folder?

Dear,

$sfUser = sfContext::getInstance()->getUser();
$sfRequest = sfContext::getInstance()->getRequest();
$sfController = sfContext::getInstance()->getController();

$sfUser->setAttribute('abc','yes');
$sfRequest->setMethod();
$sfController->redirct('cart/list');


Cheers!