Rss Feed
  1. Ajax loading

    Monday 7 July 2014

    Link: 

    http://jquery.malsup.com/block/#page

  2. To make the browser use the correct encoding, add an HTTP header like this:

    header("Content-Type: text/plain; charset=ISO-8859-1");

    or put the encoding in a meta tag:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  3. Alphanumeric, dash and underscore but no spaces regular expression check Javascript


    var regexp = /^[a-zA-Z0-9-_]+$/;
    var check = "checkme";
    if (check.search(regexp) == -1)
        { alert('invalid'); }
    else
        { alert('valid'); }


    Only Alphanumeric  regular expression check Javascript


    var regexp = /^[a-zA-Z0-9]+$/;
    var check = "checkme";
    if (check.search(regexp) == -1)
        { alert('invalid'); }
    else
        { alert('valid'); }

  4. Friendly url

    http://pt.com/sicsdev/ln10/qttracksubcampaign

    Original URL.
    http://pt.com/sicsdev/trakk/lnk/index.php?ctype=1&cparm=0&cname=qttracksubcampaign

    This URL rewrite is done in .htaccess file. Code that helped to do this is
    RewriteRule 
    -----------------------------------------------------------------------------------------------------------
    RewriteEngine On

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)/$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

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

    In this many things I had learned

    1.In the friendly url there is a parameter In10. From this parameter ctype and cparm value is obtained.

        How its possible?
         In this parameter In10, prefix part In will be static. So with the help of static value its possible to get succeeding values using regular expression. Check RewriteRule to find it out

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

           In the above rule following the static parameter value(In),([0-6]) will give first dynamic parameter value $1 also it limits value of parameter from 0 to 6.([0-2]) will give second dynamic parameter value $2 also it limits value of parameter from 0 to 2.Succeeding slash(/) is mentioned for adding third parameter.
    ([a-zA-Z0-9-\_]+) will give third parameter value $3.
    We can pass the obtained parameter value to the original URL like ?ctype=$1&cparm=$2&cname=$3

    2. ([0-6]) using this regular expression will limit parameter value.

    3. If we use all the regular expression to receive parameter value  in the RewriteRule at once as above then its mandatory to supply all the parameter through URL.

    Eg: Lets consider two url to understand

    URL 1: Need to pass two parameter at once

    Friendly Url -> www.eg.com/type/id

    Orginal Url -> www.eg.com/edit.php?t=type&id=id

    RewriteRule

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ edit.php?t=$1&id=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ edit.php?t=$1&id=$2

    In the above the case two parameter is mandatory at once. So can use above code at once for both parameter value.


    URL 2: Need to pass two parameter. But both the parameters are not mandatory.

    Friendly Url -> www.eg.com/type/id

    Orginal Url -> www.eg.com/edit.php?t=type&id=id

    RewriteRule

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ edit.php?t=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ edit.php?t=$1

    //Second Parameter 
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ edit.php?t=$1&id=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ edit.php?t=$1&id=$2

    In the above the case two parameter is  not mandatory at once. So need to use rewrite Url for both the parameters.

  5. Pretty URLs always helps you to boost up search engine page ranking. In this post I want to explain about URLs rewriting techniques using .htaccess file. Friendly URLs looks neat on the browser address bar. 

    Original URL.
    Eg. http://flickr.com/users.php?id=username&page=2 

    Rewriting Friendly URL.
    Eg. http://flickr.com/username/2

    .htaccess Code
    //First Parameer
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ users.php?user=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ users.php?user=$1

    //Second Parameter 
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2

    Demo: http://www.9lessons.info/2009/11/pretty-urls-with-htaccess-file.html


  6. Jquery get key press button event

    Friday 25 April 2014

    <input type="text" name="txt1" onKeyPress="SearchName(event)" value="<Type To Search>" >

    function SearchName(e, txtObj, selObj) {
      evt = e || window.event;
      var keyPressed = evt.which || evt.keyCode;
    }

  7. Upload file via ajax jquery php

    Monday 14 April 2014

     $.ajax({
              type : "POST",
             /* data : $('#reg-restaurant-form').serialize(),*/        
                    contentType: false,
                    processData: false,
             data :new FormData($('#reg-restaurant-form')[0]),
              url  : myBaseUrl+('/UsersActions/restaurantUserAdd'),
                    success : function(opt){
    }
    });


  8. HTML CSS Box Container

    Friday 4 April 2014

    <!DOCTYPE html>
    <html>
    <head>
    <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
      <script class="jsbin" src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
    <meta charset=utf-8 />
    <title>JS Bin</title>
    <!--[if IE]>
      <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <style>
      article, aside, figure, footer, header, hgroup,
      menu, nav, section { display: block; }
      #modal {
        width: 600px;
        border: 1px solid #CCC;
        box-shadow: 0 1px 5px #CCC;
        border-radius: 5px;
        font-family: verdana;
        margin: 25px auto;
        overflow: hidden;
      }
      #modal header {
        background: #f1f1f1;
        background-image: -webkit-linear-gradient( top, #f1f1f1, #CCC );
        background-image: -ms-linear-gradient( top, #f1f1f1, #CCC );
        background-image: -moz-linear-gradient( top, #f1f1f1, #CCC );
        background-image: -o-linear-gradient( top, #f1f1f1, #CCC );
        box-shadow: 0 1px 2px #888;
        padding: 10px;
      }
      #modal h1 {
        padding: 0;
        margin: 0;
        font-size: 16px;
        font-weight: normal;
        text-shadow: 0 1px 2px white;
        color: #888;
        text-align: center;
      }
      #modal section {
        padding: 10px 30px;
        font-size: 12px;
        line-height: 175%;
        color: #333;
      }
    </style>
    </head>
    <body>
     
      <div id="modal">
        <header><h1>Something Here</h1></header>
        <section>
          <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
          <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
          <p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>
        </section>
      </div>
     
    </body>
    </html>

    Demo:
    http://jsbin.com/ogesuf/5/edit

  9. Increase and Test Page Speed

    Thursday 3 April 2014

    To test page speed and optimization

    https://developers.google.com/speed/pagespeed/
    https://developers.google.com/speed/docs/insights/MinifyResources

    Tips to increase website speed

    http://sixrevisions.com/web-development/decrease-webpage-load-times/

    http://moz.com/blog/15-tips-to-speed-up-your-website

    http://www.webdesignerdepot.com/2013/02/how-to-speed-up-your-website-load-times/

    YUI compressor Usage

    http://chris-barr.com/2008/12/how_to_use_the_yui_compressor/

  10. <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>

    Add this code in .htaccess file to enablr Gzip compression

    Links:

    http://www.feedthebot.com/pagespeed/enable-compression.html
    http://gtmetrix.com/enable-gzip-compression.html
    http://checkgzipcompression.com/