Friday, December 23, 2011

Tool to analyse web page

A pefect tool to optimize load time.

and if you are a drupal developer, you will get a right module for all the suggestion it gives

Tuesday, December 20, 2011

Mysql indexing explained in few lines

Indexes are used to find rows with specific column values quickly. Without an index, MySQL must begin with the first row and then read through the entire table to find the relevant rows. The larger the table, the more this costs. If the table has an index for the columns in question, MySQL can quickly determine the position to seek to in the middle of the data file without having to look at all the data. If a table has 1,000 rows, this is at least 100 times faster than reading sequentially. If you need to access most of the rows, it is faster to read sequentially, because this minimizes disk seeks

What is indexing?
Indexing is a way of sorting a number of records on multiple fields. 
Creating an index on a field in a table creates another data structure which holds the field value, and pointer to the record it relates to. This index structure is then sorted, allowing Binary Searches to be performed on it.

For further reading:

29 MySQL interview questions

Saturday, December 17, 2011

What's new in drupal 7

Obviously so many things.
But as a developer one has to say few very strong feature, either to client or managers.

So here i found this

Friday, December 9, 2011

IE Unlimited CSS Loader

IE Unlimited CSS Loader

if you use drupal cache's option to optimise css files, all your css will get merge into one. so no need of this module

Monday, November 14, 2011

Google news in Hindi

Google news in हिंदी :

Reading news in hindi is always saves time for me. I know all our hindi news websites are bit cheap, and content quality is not comparative to English, like Times of India or The Hindu. But Nobody want to stare computer screen for long.
I start my day with Google news, and I enjoy reading news in my mother-tongue. 

Friday, September 9, 2011

Discount module for ubercart

I have gone through with every discount module for this. but none of them helped me. Then It was done very easily via hook_uc_cart_alter()
I feel very happy now.

Tuesday, June 28, 2011

Drupal | programmatically create node with file field

$node = new StdClass();
        $node->type = 'bzl_img';
        $node->uid = $_GET['user_id'];
        $node->status = 0;

Wednesday, March 2, 2011

.tpl file output using theme function

So, you have prepared the output in one of your module function with all complicated business logic client specified in last meeting.  Your "return ($output);" throws everything on screen. You became glad to see your code worked finally.
And if Table layout is required you pushed all html in $output variable and theming of your own module page become hectic. Better to go with tpl output.

Thursday, February 24, 2011

PHP GD Lib image generation from jpg file


function getCenterX($font_size, $font_file, $text, $img_width) {
  $box = imagettfbbox($font_size, 0, $font_file, $text);
  $text_width = $box[2] - $box[0];
// Position to align in center
  $position_center = ceil(($img_width - $text_width) / 2);

$img_width = 960;
$img_height = 640;
$font_file = 'Kentucky.ttf';
$canvas = imagecreatefromjpeg('coupan_ip4.jpg');
$pre_header = '&lt;b&gt;sare jahan se achcha hindusit';
$main_header = 'Jan gan man';
$main_description = "Main Description";
$sub_description = "Main Description";
$ccode = "Coupon Code : 112345767";
$expire = "Expires: 02/09/2011";
$ccode_server ="Server: select coupon code 18";
$disclaimer = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr,  sed diam nonumy eirmod tempor invidunt ut labore et ";

// Allocate colors
$pink = imagecolorallocate($canvas, 255, 105, 180);
$white = imagecolorallocate($canvas, 255, 255, 255);
$green = imagecolorallocate($canvas, 37, 102, 70);
$black = imagecolorallocate($canvas, 0, 0, 0);
$red = imagecolorallocate($canvas, 190, 33, 50);

imagettftext ($canvas, 20, 0, getCenterX(20, $font_file, $pre_header, $img_width), 40, $black, $font_file, $pre_header);
imagettftext ($canvas, 40, 0, getCenterX(40, $font_file, $main_header, $img_width), 100, $red, $font_file, $main_header);
imagettftext ($canvas, 18, 0, 10, 140, $green, $font_file, $main_description);
imagettftext ($canvas, 13, 0, 10, 180, $black, $font_file, $sub_description);
imagettftext ($canvas, 16, 0, 10, 200, $black, $font_file, $ccode);
imagettftext ($canvas, 13, 0, 10, 220, $black, $font_file, $expire);
imagettftext ($canvas, 13, 0, 10, 240, $black, $font_file, $ccode_server);
imagettftext ($canvas, 13, 0, 10, ($img_height-50), $black, $font_file, $disclaimer);

//echo $font_width = ImageFontWidthByFilename($font_file);
// Output and free from memory
header('Content-Type: image/jpg');