Monday 27 May 2013

Mysqldump command:

Mysqldump command:

mysqldump -hlocalhost -uroot -ppassword DBname > /var/www/path.sql

Wednesday 17 April 2013

JQuery  plug-in for Pi Charts:

data[] =

[{"name":"Koramangala","y":4,"sliced":true,"selected":true},
{"name":"Old Madras Road","y":16,"sliced":true,"selected":true}]
 
----------------------------------------------------------------- 

(function( $ ){
  $.fn.pieChartWidget = function(o) {
      var cfg={
        data : [],
        renderTo:'body',          
        sliceColors: ['#E69D01', '#BE0101', '#36AE01', '#FFCC49', '#FFF390', '#64676A']
      };
     
      jQuery.extend(cfg, o);   
     
      jQuery.extend({
            pieChart : function(params){
                Highcharts.setOptions({
                    colors: cfg.sliceColors
                  });
               
                var options = {
                        chart: {                           
                            renderTo: cfg.renderTo,
                            type: 'pie',
                            plotBackgroundColor: null,
                            plotBorderWidth: null,
                            plotShadow: false,
                            backgroundColor:'',
                            cursor:'normal'
                        },
                        title: {
                            text: ''
                        },
                     tooltip: {
                         formatter: function() {
                             var s = '';
                             if(this.point.projectName != undefined){
                              s += '<b>' + this.point.projectName  + '</b><br>';
                             }
                             if(this.point.startDate != undefined){
                                 s += 'Start Date :<b> ' + this.point.startDate + '</b><br>';
                                 s += 'End Date :<b> ' + this.point.endDate + '</b><br>';
                                 s += 'Total Assign hours :<b> ' + this.point.assignHours + '</b><br>';
                                 s += 'Total Spend hours :<b> '+ this.point.spendHours +'/' + this.point.actualHours + '</b><br>';
                             }                            
                             return s;
                         }
                     },
                        legend: {
                            enabled: true
                        },
                        credits : {
                            enabled:false
                        },
                        plotOptions: {
                            pie: {
                                allowPointSelect: true,
                                cursor: 'pointer',
                                shadow: false,
                                size:'100%',
                                borderWidth: 1,
                                dataLabels: {
                                enabled: true,
                                color:'#FFFFFF',
                                padding:1,
                                style: {
                                    fontWeight:'bold'
                                }, 
                                formatter: function () {
                                  return '<b>'+this.y+'%</b>';
                                },
                                distance: -40
                              },
                              showInLegend: false,
                              states: {
                                    hover: {
                                        enabled: false
                                    }
                                },
                                animation: true,
                            }
                          },
                        exporting: {
                            enabled: false
                        },
                        series: [{
                            data: [],
                           
                        }]
                    };
                    jQuery.extend(options, o);
                    options.series[0].data = cfg.data;                   
                    chart = new Highcharts.Chart(options);
            }
        });
       
        return this.each(function(){
            jQuery.pieChart(cfg.data);
        }).extend({
            cfg : cfg,
            jQuery : jQuery
        });
  };
})( jQuery );

------------------------------------------------------------------------------------------------------------------------------------

Plug-in calling

     $.post(path,{
         selectedtab:selected_tab
     },function(pieData){
         if(jQuery.isEmptyObject(pieData) != true){
                 $('#widget_content').pieChartWidget({                
                     renderTo: 'widget_content',
                     data: pieData,          
                 });
         }else{
             $('#widget_content').pieChartWidget({                
                  renderTo: 'widget_content',
                  sliceColors: ['#ccc'],
                  data:[{name: 'No data',y: 100,sliced: true,selected: true}],          
              });
         }
    },'json');



 

Monday 8 April 2013

Permanently setting auto_increment_offset and auto_increment_increment in MySQL.

ALTER TABLE tablename AUTO_INCREMENT = 1;

mysql> SHOW VARIABLES LIKE 'auto_inc%';
+-----------------------------------+-------+
| Variable_name                     | Value |
+-----------------------------------+-------+
| auto_increment_increment   |   1     |
| auto_increment_offset          |   1     |
+------------------------------------+-------+
2 rows in set (0.00 sec)


auto_increment_increment controls the interval between successive column values. Default value 1.


SET GLOBAL auto_increment_increment  = 2;
SET SESSION auto_increment_increment = 2;

(or)

SET @@global.auto_increment_increment = 2;
SET @@session.auto_increment_increment = 2;


auto_increment_offset determines the starting point for the AUTO_INCREMENT column value.


SET GLOBAL auto_increment_offset  = 2;
SET SESSION auto_increment_offset  = 2;

(or)

SET @@global.auto_increment_offset = 2;
SET @@session.global.auto_increment_offset = 2;
 
restart mysql server (if Required)
sudo service mysql restart  

If the global value of either variable is set, its effects persist until
the global value is changed or overridden by setting the session value,
or until mysqld is restarted. If the local value is set, the new value 
affects AUTO_INCREMENT columns for all tables into which new rows are 
inserted by the current user for the duration of the session, unless the
values are changed during that session.



Thursday 4 April 2013

Virtual host configuration for Symfony2 project on ubuntu.
 (In Development Environment )
Open Terminal and execute below steps
  1. Go to : sudo gedit /etc/apache2/sites-enabled/000-default
  2. Edit: 
<VirtualHost *:80>
    DocumentRoot /var/www/sample/web
    ServerName sample.com
   
    <Directory /var/www/sample/web/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all

        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ /app_dev.php [QSA,L]
        </IfModule>
    </Directory>
</VirtualHost>

    3.  Go to: sudo gedit /etc/hosts
    4.  Edit :
         127.0.0.1 sample.com 
    5. Restart apache server: sudo service apache2 restart
    6. Open browser and type http://sample.com/app_dev.php
     
 Enjoy...