Sunday, August 12, 2012

JQuery Datatable

DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table. Key features:
So how easy is it to use DataTables? Take a peek at the code below, a single function call to initialise the table is all it takes:
1
2
3
4
5
6
/*
 * Example init
 */
$(document).ready(function(){
    $('#example').dataTable();
});
An example of DataTables in action is shown below with a table of CSS browser grading as used by Conditional-CSS.

DataTables around the web

Thursday, August 9, 2012

How to Add the Facebook Like Button


This Tutorial will help you in adding a Facebook Like Button For Blogger. Facebook has come up with a new set of Social plugins which enable you to provide engaging social experiences to your users with just a line of HTML. The Facebook Like Button is One of them. You can see a demo of the like button on this page. The Facebook like button will allow your readers to quickly share your posts with their Facebook Friends. You can also get to know how many people liked your Blog Post .This tutorial will teach you to add a Facebook Like button for Blogger

How to Add the Facebook Like Button Below every Post

1. First Generate the Facebook code using the options below. (Code will be updated with these details)
Button Type
Text on Button
Show Send Button
Color Scheme
Font
Float
Location of the Button
Display
> arial" action="like" colorscheme="light"> 2. Copy the Above code. Login to your Blogger Account and go to Design > Edit HTML and click on the check box which says “Expand Widget Templates
3. Look for and immediately below that place the copied code.
4.Next you have to add the fb namespace to your template tag.Your template should have the specification for the fb tag that you have used. The following namespace declaration will take care of that. To declare the namespace, find
and change it to

The following screenshot will help you out.

image 
 
This is necessary for all FBML widgets using the fb tag.  So if you have already added the namespace while adding some other FB plugin, then you can skip this.

4. Now Save the template and you should see the Like Button near each of your posts. You are done :)

Wednesday, August 8, 2012

TCPDF Examples: PHP class for generating PDF documents

  1. [PDF] [PHP] first example with default Header and Footer
  2. [PDF] [PHP] without Header and Footer
  3. [PDF] [PHP] custom Header and Footer
  4. [PDF] [PHP] text Stretching with Cell()
  5. [PDF] [PHP] Multicell()
  6. [PDF] [PHP] WriteHTML()
  7. [PDF] [PHP] independent columns with WriteHTMLCell()
  8. [PDF] [PHP] external UTF-8 Unicode text file
  9. [PDF] [PHP] Image()
  10. [PDF] [PHP] text on multiple columns
  11. [PDF] [PHP] table with primitive methods
  12. [PDF] [PHP] graphic methods
  13. [PDF] [PHP] graphic transformations
  14. [PDF] [PHP] forms and javascript
  15. [PDF] [PHP] index with Bookmarks()
  16. [PDF] [PHP] document encryption
  17. [PDF] [PHP] independent columns with MultiCell()
  18. [PDF] [PHP] Persian and Arabic language on RTL document
  19. [PDF] [PHP] alternative config file
  20. [PDF] [PHP] complex alignment with Multicell()
  21. [PDF] [PHP] writeHTML() text flow
  22. [PDF] [PHP] CMYK colors
  23. [PDF] [PHP] page groups
  24. [PDF] [PHP] object visibility with setVisibility() and layers with startLayer()
  25. [PDF] [PHP] object transparency with SetAlpha()
  26. [PDF] [PHP] text clipping
  27. [PDF] [PHP] 1D barcodes
  28. [PDF] [PHP] multiple page formats
  29. [PDF] [PHP] Set PDF viewer display preferences with setViewerPreferences()
  30. [PDF] [PHP] colour gradients
  31. [PDF] [PHP] pie chart graphic
  32. [PDF] [PHP] EPS/AI vectorial image with ImageEPS()
  33. [PDF] [PHP] mixed font types (TrueType Unicode, core, CID-0)
  34. [PDF] [PHP] clipping masks
  35. [PDF] [PHP] border styles with SetLineStyle()
  36. [PDF] [PHP] PDF text annotations
  37. [PDF] [PHP] spot colors
  38. [PDF] [PHP] unembedded CID-0 CJK font
  39. [PDF] [PHP] HTML text justification
  40. [PDF] [PHP] booklet mode (double-sided pages)
  41. [PDF] [PHP] file attachment
  42. [PDF] [PHP] image with transparency (alpha channel)
  43. [PDF] [PHP] disk caching
  44. [PDF] [PHP] move, copy and delete pages
  45. [PDF] [PHP] table of contents
  46. [PDF] [PHP] text hyphenation
  47. [PDF] [PHP] transactions and UNDO
  48. [PDF] [PHP] HTML tables with header and rowspan
  49. [PDF] [PHP] call TCPDF methods in HTML
  50. [PDF] [PHP] 2D barcodes (QR-Code, Datamatrix ECC200 and PDF417)
  51. [PDF] [PHP] image as a page background
  52. [PDF] [PHP] digital signature certification
  53. [PDF] [PHP] javascript functions
  54. [PDF] [PHP] XHTML form
  55. [PDF] [PHP] core fonts dump
  56. [PDF] [PHP] crop marks and registration marks
  57. [PDF] [PHP] vertical alignment and metrics on Cell()
  58. [PDF] [PHP] SVG vectorial image with ImageSVG()
  59. [PDF] [PHP] table of contents with HTML templates
  60. [PDF] [PHP] advanced page settings
  61. [PDF] [PHP] XHTML + CSS
  62. [PDF] [PHP] XObject templates
  63. [PDF] [PHP] text stretching and spacing (tracking/kerning)
  64. [PDF] [PHP] no-write page regions
  65. [PDF] [PHP] PDF/A-1b (ISO 19005-1:2005) document

Removing index.php from codeigniter URL

Removing index.php from codeigniter URL


Open config.php from system/application/config directory 
 
and replace
 
$config['index_page'] = index.php by $config['index_page'] = “”
 
Create a “.htaccess file in the root of CodeIgniter directory 
 
and add the following lines.
 
RewriteEngine onRewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php/$1 [L,QSA]
 
In some case the default setting for uri_protocol does not work properly. 
 
 To solve this problem just replace 
 
$config['uri_protocol'] = AUTO by 
 
 $config['uri_protocol'] = REQUEST_URI from system/application/config/config.php

PHP : create unique array using array_map

PHP : create unique array using array_map


array(
 array( "Title", 50, 96 ),
 array( "Other Title", 110, 225 ),
 array( "Title", 110, 225 ),
 array( "Title", 110, 225 ),
)
 
From this array we can show only unique array elements using following function.
 
$input = array_map("unserialize", array_unique(array_map("serialize", $input)));
 
 
Output
 
array(
 array( "Title" => array( 50, 96 ), array(110, 225) )
 array( "Other Title", array( 110, 225 ) )
)
 

jQuery UI dialog

 
 
Create a dialog window using jQuery UI 
 
Include following files.
 
 
rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/base/jquery-ui.css">      
rel="stylesheet" type="text/css" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css">                  
 HTML sample 

 <a id="forgot">Click me to open dialog</a>


<div id="dialog-form" title="Add New ">
    <p class="validateTips">All form fields are required.</p>
    <form id="forgotform" action="/forgotPassword.php" method="post">
    ..................
    </form>
</div

 jQuery


$("#forgot").click(function(e){
    $("#dialog-form").dialog("open");
    e.preventDefault();
});

$("#dialog-form").dialog({
            modal: true,
            autoOpen: false,
            height: 255,
            width: 300,
            buttons: {
                "Retrieve": function() {
                    document.forms["forgotform"].submit();
                },
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            },
});


demo 

How to import json array into jQuery calendar

Hi
I'm trying to feed a jQuery calendar with data from Silverstripe. I've installed the perfectly well-working Calendar Event module, but all I want now is to pull out some Calendar Events and return them as a json array. Here is the code for initiating the calendar:
$(document).ready(function() {
   
      $('#calendar').fullCalendar({
         draggable: true,
         events: "json_events.php",
         eventDrop: function(event, delta) {
            alert(event.title + ' was moved ' + delta + ' days\n' +
               '(should probably update your database)');
         },
         loading: function(bool) {
            if (bool) $('#loading').show();
            else $('#loading').hide();
         }
      });
      
   });
And here is the json_events.php:
   $year = date('Y');
   $month = date('m');
   echo json_encode(array(
   
      array(
         'id' => 1,
         'title' => "Event1",
         'start' => "$year-$month-10",
         'url' => "http://yahoo.com/"
      ),
      
      array(
         'id' => 2,
         'title' => "Event2",
         'start' => "$year-$month-20",
         'end' => "$year-$month-22",
         'url' => "http://yahoo.com/"
      )
   
   ));
?>

Window setInterval() Method

Definition and Usage

The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
The setInterval() method will continue calling the function until clearInterval() is called, or the window is closed.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method.
Tip: 1000 ms = 1 second.

Syntax

setInterval(code,millisec,lang)

Parameter Description
code Required. The function that will be executed
millisec Required. The intervals (in milliseconds) on how often to execute the code
lang Optional. JScript | VBScript | JavaScript


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari
The setInterval() method is supported in all major browsers.

Example

Example

Call the clock() function every 1000 millisecond. The clock() function updates the clock. The example also have a button to stop the clock:









How to upload image file to remote server with PHP cURL

How to upload image file to remote server with PHP cURL

In this example we learn how to upload static files to remote server using PHP cURL library.

We must know following functionality before we continue this example

Files and Folders

Download Example

For this example we use three files
  • uploader.php -that receives the files on to the remote server.
  • handler.php -is used to web based client to upload the file.
  • curl_handler.php -PHP cURL uploading client to upload file.
Since we use same host to both local and remote server ,we create separate directories
  • local_files/ - these files will be uploaded to the remote server ,means to uploaded_files directory.
  • uploaded_files/ – these files are from the uploading client from both web based and PHP cURL based.

uploader.php

 
$upload_directory=dirname(__FILE__).'/uploaded_files/';
//check if form submitted
if (isset($_POST['upload'])) {  
    if (!empty($_FILES['my_file'])) { 
   //check for image submitted
      if ($_FILES['my_file']['error'] > 0) { 
   // check for error re file
            echo "Error: " . $_FILES["my_file"]["error"] ;
        } else {
   //move temp file to our server            
   move_uploaded_file($_FILES['my_file']['tmp_name'], 
   $upload_directory . $_FILES['my_file']['name']); 
   echo 'Uploaded File.';
        }
    } else {
         die('File not uploaded.'); 
   // exit script
    }
}
handler.php





curl_handler.php

$local_directory=dirname(__FILE__).'/local_files/';
 
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
    curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_URL, 'http://localhost/curl_image/uploader.php' );
 //most importent curl assues @filed as file field
    $post_array = array(
        "my_file"=>"@".$local_directory.'shreya.jpg',
        "upload"=>"Upload"
    );
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch);
 echo $response;

jQuery Multi select box


Found a jQuery snippet for  Multi select box.

 HTML :

<select multiple="multiple">
<option value="foo">foo</option>
<option value="bar">bar</option>
<option value="baz">baz</option>
</select>

<div id="target">target</div>


 Jquery 1.4 

var target = $("#target");

$("select")
    .multiselect()
    .bind("multiselectclick multiselectcheckall multiselectuncheckall", function( event, ui ){
        
        // the getChecked method returns an array of DOM elements.
        // map over them to create a new array of just the values.
        // you could also do this by maintaining your own array of
        // checked/unchecked values, but this is just as easy.
        var checkedValues = $.map($(this).multiselect("getChecked"), function( input ){
            return input.value;
        });
        
        // update the target based on how many are checked
        target.html(
            checkedValues.length
                ? checkedValues.join(', ')
                : 'Please select a checkbox'
        );
    })
    .triggerHandler("multiselectclick"); // trigger above logic when page first loads


CSS:

#target { padding: 5px; border: 1px solid #000; width:200px; float:right }

JS Fiddle link :  http://jsfiddle.net/ehynds/rTjkr/

Tuesday, August 7, 2012

Yii Playground


Found some cool widgets for yii framework....Check it out

PHP: How to avoid a system generated e-mail going into spam?

Something that gets overlooked often: If you are sending mail manually (i.e. with mail(), not with a framework) and using sendmail, make sure you set the SMTP envelope sender address.
$headers = "MIME-Version: 1.0\r\n"
  ."Content-Type: text/plain; charset=utf-8\r\n"
  ."Content-Transfer-Encoding: 8bit\r\n"
  ."From: =?UTF-8?B?". base64_encode($from_name) ."?= <$from_address>\r\n"
  ."X-Mailer: PHP/". phpversion();
mail($to, $subject, $body, $headers, "-f $from_address");
-f tells sendmail what address to use in the SMTP wrapper; by default it is the real hostname of the machine, while the from address tends to be an alias. Some spam filters get jumpy when the two addresses don't match.
Other, more obvious advice:
  • make sure the from/reply to address resolves to the machine you are actually sending from
  • make sure no spam gets sent from your machine (open relay, other users, a website where you can enter any email address without confirmation)
  • don't use techniques which are used by spammers to trick filters (e.g. text as image)

Android Application Development 200 Videos

Welcome to the new website! As you have noticed, several changes have been made in order to improve speed and maximize the performance of the website. If you find any bugs, receive any error messages, or have any suggestions/recommendations, please contact me at bucky_roberts@yahoo.com and let me know. Thank you and enjoy the new site! -Bucky

Android Application Development

200 Videos