Thursday, 20 September 2018

How to modify MySQL database configuration in AWS RDS


This decade is too fast then expected by technology leaders. So, let's come to the main point without talking unnecessary thinks.
In this article, I explaining how to modify MySql parameters while you are using AWS RDS (Relational Database Service) for MySql Database.I write this post after fixing an error of "MySql 'max_allowed_packet' bytes error during import database" but you can do anything with MySql database configuration parameters after reading this post. Let's start step by step how to fix this and many more things.
After reviewing this article I understand what I have to do and how.
Here are the following steps.
  1. Go to RDS page and click on "Parameter groups" text located in the left navigation.
    CEHag.png
  2. Now create a new group by clicking on "Create parameter group" orange button.
    yHg2I.png
  3. Fillup parameter group form "Parameter group family" should be MySql version of your RDS instance than "Group name" and "Description" whatever you want.
    O1FWD.png
  4. New "Parameter group" was created as "test" now edit it and increase "max-allowed-packet" by entering "10000000" (10 MB) value should be in Bytes after entering value don't forgot to click on "Save changes" button and make sure value is between 1024 Bytes to 1073741824 Bytes (1073 MB)
    279Bx.png
  5. Now you can see your changes by click on "Preview changes" button.
  6. Now we have to change the "Parameter group" in our RDS instance. SO, modify an instance and select "Parameter groups" which we created.
    TXLlR.png
  7. Now after modifying RDS instance, you should Reboot it to apply your changes.

Read on StackOverflow


It's an output of research and self-motivation to learn something new and make development like Music.😃

Friday, 16 September 2016

How to calculate the difference between two dates using PHP




function DateDiff($startDate, $endDate) {
        
    $startDate = strtotime($startDate);
    $endDate = strtotime($endDate);

    if ($startDate === false || $startDate < 0 || $endDate === false || $endDate < 0 || $startDate > $endDate){
        return false;
    }

    $years = date('Y', $endDate) - date('Y', $startDate);

    $endMonth = date('m', $endDate);
    $startMonth = date('m', $startDate);

    /*** Calculate months ***/
    $months = $endMonth - $startMonth;
    if ($months <= 0) {
        $months += 12;
        $years--;
    }

    if ($years < 0){
        return false;
    }

    /*** Calculate the days  ***/
    $offsets = array();
    if ($years > 0){
        $offsets[] = $years . (($years == 1) ? ' year' : ' years');
    }
    if ($months > 0){
        $offsets[] = $months . (($months == 1) ? ' month' : ' months');
    }
    $offsets = count($offsets) > 0 ? '+' . implode(' ', $offsets) : 'now';

    $days = $endDate - strtotime($offsets, $startDate);
    $days = date('z', $days);

    return array($years, $months, $days);
}

Saturday, 21 May 2016

Hwo to install NodeJS In Ubuntu



Quick video showing you how to setup Node.js with ExpressJs and NPM in Ubuntu in just a few minutes.

Tuesday, 1 December 2015

Ajax file upload with progress Bar

$("form#imageuploadform").on("submit", function (e) {

    var formData = new FormData($(this)[0]);    
    var timestamp = $("form#imageuploadform input#timestamp").val();
    $.ajax({
        url: shr_ajax.ajaxurl,        
        type: 'POST',        
        enctype: 'multipart/form-data',        
        data: formData,
        dataType: "json",
        xhr: function () {
            var myXhr = $.ajaxSettings.xhr();
            if (myXhr.upload) {
                myXhr.upload.addEventListener('progress', progress, false);
            }
                return myXhr;
        },
        cache: false,
        contentType: false,
        processData: false,
        success: function (data) {

            if (data.id == timestamp && data.success === true) {
                alert(data.message);
                $("#import_user_csv").removeAttr("disabled");
                $("#import_user_data_form").css("opacity", "1"); 
           }
            if (data.id == timestamp && data.success === false) {
                alert(data.message);
            }
            $('form#imageuploadform')[0].reset();
        }, 
       error: function (data) {
            console.log(data);
            $('form#imageuploadform')[0].reset();
        }
    });
    e.preventDefault();
});

function progress(e) {

    if (e.lengthComputable) {
        var max = e.total;        var current = e.loaded;
        var Percentage = (current * 100) / max;
        var percent_upload = Math.round(Percentage);
        console.log(percent_upload);
        jQuery("#percent_upload").css("width", percent_upload + "%");
        jQuery("#percent_upload").text(percent_upload + "%");
        if (Percentage >= 100) {
            //alert("Uploading finish.");
        }
    }

}

Sunday, 28 June 2015

Media Queries for Standard Resolutions

/* mobile*/
@media (max-width: 320px) { }


/*Smartphones*/
@media (max-width: 480px) { }


/* Smartphones to Tablets */
@media (min-width: 481px) and (max-width: 767px) { }


/* Tablets */
@media (min-width: 768px) and (max-width: 959px) { }


/* Desktop */
@media (min-width: 960px) and (max-width: 1199px) { }


/* Desktop */
@media (min-width: 1200px) { }

Saturday, 2 May 2015

How do i remove a pre exising customizer setting in wordpress theme



add_action( 'customize_register', 'ruth_sherman_theme_customize_register' );
function ruth_sherman_theme_customize_register( $wp_customize ) {

$wp_customize->remove_control('header_image');
$wp_customize->remove_panel('widgets');

$wp_customize->remove_section('colors');
$wp_customize->remove_section('background_image');
$wp_customize->remove_section('static_front_page');

}

Monday, 9 February 2015

jquery parallax background image

$(document).ready(function(jQuery) {

    $('.my_testimonial').each(function($) {

// assigning the object
var bgobj = jQuery(".my_testimonial");

        jQuery(window).scroll(function($){

            var sco_top = jQuery(window).scrollTop();
            var yPos = -(sco_top / 1.7);

            // Put together our final background position
            var coords = '50% ' + yPos + 'px';
            console.log(coords);

            // Move the background
            jQuery(".my_testimonial").css("backgroundPosition", coords);

        });
    });

});

Get post between dates in wordpress




$args = array(
'posts_per_page'   => -1,
'order'            => 'DESC',
'post_type'        => 'post',
'post_status'      => 'publish',
'cat'          => 59,
'date_query'  => array(
array(
'after'     => array(
'year'    => 2015,
'month'   => 02,
'day' => 06,
'hour' => 10,
'minute'  => 28,
'second'  => 55,
),
'before'    => array(
'year'    => 2015,
'month'   => 02,
'day' => 09,
'hour' => 15,
'minute'  => 24,
'second'  => 01,
),
),
),
);

$query_result = new WP_Query($args);


User can access only own media in wordpress




add_filter( 'ajax_query_attachments_args', 'show_users_own_attachments', 1, 1 );

function show_users_own_attachments($query){
  $id = get_current_user_id();
  if( !current_user_can('manage_options') )
  $query['author'] = $id;
  return $query;
}

Wednesday, 28 January 2015

Facebook & instagram Went Down on 27 Jan 2015 for an one hour.

Facebook blames technical hitch after social media sites including Instagram and Tinder go down for an hour... but hackers claim THEY were responsible.




  • Millions locked out of Facebook and Instagram for around an hour
  • Hackers from the online group Lizard Squad have claimed responsibility 
  • Mark Zuckerberg's social media sites have denied it was a cyber attack 
  • Blamed the outage on 'a change that affected our configuration systems'
  • AIM, Tinder and MySpace were also claimed to have been offline    
  • Lizard Squad hit Malaysia Airlines, Sony and Xbox in past month

Friday, 19 December 2014

Plugin 'federated' is disabled. xampp

I have find solution for this error in xampp

1) On start MySQL service we have face some problem



2) Solution for this Error Plugin 'FEDERATED' is disabled.
     Just open Task Manager and go in Details tab then find mysqld.exe file stop this task.


3) Let's Re-try  start MySQL Service and see it's working.


Sunday, 9 November 2014

Shift click select multiple items like gmail

Shift click select multiple items like gmail. you can change any types of elements like check , div, a, label, any html tags.




Multiple selected view

Selected thumb id

Saturday, 13 September 2014

How do I keep two divs that are side by side the same height

Step 1 Css

    <style type="text/css">

     html{ height:100%;}

     body{ position:absolute; width:100%; height:100%; padding:0; margin:0; font-family:Arial, Helvetica, sans-serif; font-size:15px; color:#333;}

     .wp{ width:1000px; margin:0 auto; height:100%;}

     .left_part{ background:#eee; color:#333; text-align:center; height:100%; float:left; width:300px;}

     .right_part{ background:#ccc; color:#333; text-align:center; height:100%; float:left; width:700px;}

    </style>


Step 2 Html

<body>
    <div class="wp">
       <div class="left_part"> Left Div <br/> Padding top and bottom not allowd </div>
       <div class="right_part"> Right Div <br/> Padding top and bottom not allowd  </div>
    </div>
 </body>
    

Friday, 5 September 2014

Magento get category tree view

Output View


Step 1 Goto theme/layout/catalog.xml put this code in file


    <reference name="left">
    <block type="catalog/navigation" name="category_list_sidebar" template="catalog/navigation/categorymenu.phtml"/>
    </reference>

Step 2 Goto theme/template/catalog/ thane create navigation folder and put categorymenu.phtml file inside.


<?php
    $_helper = Mage::helper('catalog/category');
    $_categories = $_helper->getStoreCategories();
    $currentCategory = Mage::registry('current_category');
    ?>
    <div class="block block-list block-categorys">
        <div class="block-title">
       <strong><span>Category</span></strong>
        </div>
    <div class="block-content">
        <ul class="category_sub">
    <?php if (count($_categories) > 0){ ?>
    
                    <?php
    global $index;
    global $data;
   
    foreach($_categories as $_category){
    
    $check_child_class = check_child_par($_category->getId());
    $collaps = ($check_child_class)? "<span class='show-cat'>+</span>" : "";
    echo "<li class='".$check_child_class."'>";
    echo "<a href='".$_helper->getCategoryUrl($_category)."'>".$_category->getName();
    echo " (".product_count($_category->getId()).")";
    echo "</a>".$collaps;
    echo check_child($_category->getId());
    echo "</li>";
   
    }
    }
    function check_child($cid){
    $_helper = Mage::helper('catalog/category');
    $_subcategory = Mage::getModel('catalog/category')->load($cid);
    $_subsubcategories = $_subcategory->getChildrenCategories();
   
    if (count($_subsubcategories) > 0){
    echo "<ul>";
    foreach($_subsubcategories as $_subcate){
   
    $check_child_class = check_child_par($_subcate->getId());
    $collaps = ($check_child_class)? "<span class='show-cat'>+</span>" : "";
   
    echo "<li class='".$check_child_class."'>";
    echo "<a href='".$_helper->getCategoryUrl($_subcate)."'>".$_subcate->getName();
    echo " (".product_count($_subcate->getId()).")";
    echo "</a>".$collaps;
    echo check_child($_subcate->getId());
    echo "</li>";
    }
    echo "</ul>";
    }else{
    return "";
    }
    }
   
   
    function check_child_par($cid){
   
    $_subcat = Mage::getModel('catalog/category')->load($cid);
    $_subsubcats = $_subcat->getChildrenCategories();
   
    if (count($_subsubcats) > 0){
    return "parent";
    }else{
    return "";
    }
    }
   
    function product_count($cid){
    $products_count = Mage::getModel('catalog/category')->load($cid)->getProductCount();
    return $products_count;
    }
    ?>
    </ul>
    </div>
    </div>

Thursday, 4 September 2014

Magento import newsletter subscribers csv

Step 1
Add import.php file in Magento root directory 

Step 2
Add subscribers.csv file in Magento root directory

Step 3
Run import.php file in root directory like ( http://localhost/magento/import.php )

Step 4
Go to admin menu Newsletter > Newsletter Subscribers and finally you subscriber user CSV file import