Friday, December 16, 2011

Facebook javascript error - perms should now be called scope

From December 13th onwards, facebook supports only OAuth 2.0 for authentication. First introduction of Oauth 2.0 in the javascript SDK was in July 2011. All apps were given time untill October 11 to migrate to OAuth 2.0.

Please ensure that response.session will be replaced with response.authResponse.

Cool Resignation Letter



Dear HR MANAGER NAME,

Please accept this letter as my formal notice of resignation from COMPANY NAME, effective DATE. The associations I’ve made during my employment here will truly be memorable for years to come.

The feeling is mixed as this the first company that provided me with a platform to help me find what I am, by giving me the right opportunity. Even though this should be a formal letter I cannot help to express my gratitude and feelings by a simple poem :

I love This Job
But I have to Go
Because I have Got Something
Which I cant Ignore

I Aimed for the Sky
I got the Stars
And I Saw the World Beyond
That I want to Explore

This isn’t for Money, this isn’t my Greed
This isn’t about People that make me Crib
But this is about the Dreams I have always had
A flick of Hope that makes me Mad

I am Upset, I feel Sad
To leave the World I created from Scratch
But now is the age to take more Risk
And this is the Opportunity I could not Miss


Separation will be Painful that’s what it Seems
For I would miss the Boss and the Entire Team
Our Relationship is Eternal and the world is small
And I would be in touch with One and All

I hope 2 weeks notice is sufficient for arranging new employee as my replacement. I can train the new employee during my notice period. Also I am available to tie up any loose ends if there is need of it.

Thank you very much for providing golden opportunity to be part of your organization.

Sincerely,

NAME,
DESIGNATION
COMPANY NAME

Monday, December 12, 2011

Parse blog to find keywords

We are using php to find relevent blogs based on keywords

$blog_data = array(
            'campaign_id' =>$campaign['campaign_id'],
            'campaign_name' => $campaign['campaign_name'],
            'mandatory_keywords' => $mandatory_keywords,
            'extra_keywords' => $extra_keywords,
            'page_url' => $get_blog['page_url'],
            'page_id' => $get_blog['id'],
            'html' => $get_blog['page_text']
        );
        $blog_parse_result = parse_blog_data($blog_data);









function parse_blog_data($data)
{
    show( "Parse text for: ".$data['page_url']);


    $keywords = array_merge($data['mandatory_keywords'],$data['extra_keywords']);
$page_id=$data['page_id'];//Page id for statistics_pages
$page_url=$data['page_url'];//Page id for statistics_pages
#show( "page url= ".$page_url."<br>");
    if(empty($keywords)){
#        update_blog_row($data['id'],"","NOT_OK",$page_id);
    #    show( "\n************** END: NO KEYWORDS {$data->campaign_name} ($data->campaign_id) ****************\n\n");
        return;
    }

    require_once("blog_parser/phpQuery.php");
    $doc = phpQuery::newDocumentHTML($data['html']);

    $text = "";
    $images = array();

    foreach(pq('p,h1,h2,h3') as $p)
    {
        $p_text = pq($p)->html();

        foreach($keywords as $key)
        {
            #show(  "{$key} > ");
            if(!empty($p_text) && !empty($key) && strpos(strip_tags($p_text), $key))
            {
                // Retrieve text
                $text .= !empty($text) ? "\n\n".strip_tags($p_text) : strip_tags($p_text);

                // retrieve blog images
                foreach(pq($p)->children("img") as $img)
                {
                    $src = pq($img)->attr("src");

                    if(!empty($src) && @GetImageSize($src))
                        $images[] = $src;
                }
                #show("MATCH ************************************************************");
                continue 2; // Finished parsing this p-tag
            }else
            {
                #show("NO MATCH");
            }
        }
    }

    return array(
        'status' => (!empty($text) ? "OK" : "NOT_OK"),
        'text' => utf8_decode($text),
        'images' => $images
        );
}

Cakephp mode rewrite issue

Please type the following commands, one by one in your terminal

sudo rm /etc/apache2/mods-enabled/rewrite.load

sudo a2enmod rewrite

sudo service apache2 restart

Salary increment request letter

Hi HR,

I have been employed with this company since last May 2011, as an software engineer, during which period I have discharged my duties to the best of my abilities. I have been sincerely dedicated and continuing hard-work for our company. According to my commitment to job and obeyness the management as well as experience.

So, may I now request you to consider my an increment. I hope you will take a favorable view and I feel confident that the management will be generous in recognizing and rewarding my merit.
I'm looking forward to a favorable response from you.

Sunday, November 27, 2011

Thumbnail of Images in php


function create_thumbnail($source,$destination,$thumb_width)
{


$size = getimagesize($source);

$width = $size[0];
$height = $size[1];
$x = 0;
$y = 0;
if($width > $height) {
$x = ceil(($width - $height) / 2 );
$width = $height;
} else if ($height > $width)
{
$y = ceil(($height - $width) / 2);
$height = $width;
}

$new_image = imagecreatetruecolor($thumb_width,$thumb_width);

$extension = $this->get_image_extension($source);

if($extension == 'jpg' || $extension == 'jpeg')
{
$image = imagecreatefromjpeg($source);

}
if($extension == 'gif')
{
$image = imagecreatefromgif($source);

}
if($extension == 'png')
{
$image = imagecreatefrompng($source);

}

imagecopyresampled($new_image,$image,0,0,$x,$y,$thumb_width,$thumb_width,$width,$height);

if($extension == 'jpg' || $extension = 'jpeg')
{
imagejpeg($new_image,$destination);
}
if($extension == 'gif')
{
imagegif($new_image,$destination);
}
if($extension == 'png')
{
imagepng($new_image,$destination);
}

}


function get_image_extension($name)
{
$name = strtolower($name);
$i = strpos($name,".");
if(!$i) { return ""; }
$l = strlen($name) - $i;
$extension = substr($name,$i+1,$l);
return $extension;
}



function resizeGalleryImage($source)
{

$size = getimagesize($source);

$width = $size[0];
$height = $size[1];

if($width > 400)
{
$this->create_thumbnail($source,$source,400);

}
}

Thursday, October 20, 2011

Blog posts in website

We can get blog posts of our  blogs into our websites. It easier than i thought. What you need is your blog id. You can get blog id by visiting your blog dashboard and add new posts, then look into the URL, you will get a blog-id.

The code is given below



<?php
function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
    $arrData = array();
   
    // if input is object, convert into array
    if (is_object($arrObjData)) {
        $arrObjData = get_object_vars($arrObjData);
    }
   
    if (is_array($arrObjData)) {
        foreach ($arrObjData as $index => $value) {
            if (is_object($value) || is_array($value)) {
                $value = objectsIntoArray($value, $arrSkipIndices); // recursive call
            }
            if (in_array($index, $arrSkipIndices)) {
                continue;
            }
            $arrData[$index] = $value;
        }
    }
    return $arrData;
}
//7082666587974105933 ---My  blog id
$blogDetails = file_get_contents('http://www.blogger.com/feeds/7082666587974105933/posts/default');
$blogDetails = simplexml_load_string($blogDetails);
$blogDetails = objectsIntoArray($blogDetails);
echo "<pre>";
print_r($blogDetails['entry']);
echo "</pre>";


?>

Wednesday, July 20, 2011

Google Swiffy

Hi friends,

Yesterday Google introduced a new product in their labs(Google labs). It looks awesome. Swiffy will convert all the swf flash files to HTML5 equivalent, which support all the modern browsers. It may not support IE as of now ( I need to verify it).This version of Swiffy will not convert all the flash contents, but will be very useful in converting all the Flash advertisements in our websites.

Swiffy uses JSON for it's animation, which can be rendered using SVG, HTML5 and CSS3. All the actionscript are rendered as JSON objects and is interpreted as javascript in the browser.


Pieter Senster, is the brain behind this awesome product.

You can see some of the examples of Swiffy from here http://swiffy.googlelabs.com/gallery.html

Monday, July 11, 2011

Youtube video thumbnail using php

Youtube video thumbnail using php



php function to convert youtube url to video id


function getYouTubeIdFromURL($url)
{
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $args);
return isset($args['v']) ? $args['v'] : false;
}


Calling the above function

$youtube_id = getYouTubeIdFromURL("http://www.youtube.com/watch?v=4OoC8ycuCo0&feature=topvideos_sports");



echo $youtube_id."<br/>";

echo "http://img.youtube.com/vi/".$youtube_id."/0/.jpg"; */



The javascript version of the above code can be found in this blog

Youtube video thumbnail image using javascript

Javascript function to get video thumbnail image from youtube

The code

function getScreen( url, size )
{
if(url === null){ return ""; }

size = (size === null) ? "big" : size;
var vid;
var results;

results = url.match("[\\?&]v=([^&#]*)");

vid = ( results === null ) ? url : results[1];

if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
}else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}


Calling the javascript function and alerting the result

var result = '';

result = getScreen( 'http://www.youtube.com/watch?v=4OoC8ycuCo0&feature=topvideos_sports', 'small' );

alert(result);


The php version of the above code can be found in this blog

How to check system configuration in ubuntu?

System Configuration in Ubuntu

Command to find cpu information cat /proc/cpuinfo 

The output of the above command will be

processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model : 95
model name : AMD Athlon(tm) 64 Processor 3000+
stepping : 2
cpu MHz : 1000.000
cache size : 512 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 1
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow up extd_apicid pni cx16 lahf_lm svm extapic cr8_legacy
bogomips : 2000.17
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc


Command to find RAM details free -m

You can use the following command to find out the total RAM
grep MemTotal /proc/meminfo


Saturday, July 9, 2011

Google Scribe

I would like to introduce you a new Google product for SEO purposes, called the Google Scribe. Why do we use scribe? Now google started to look at spelling and grammar of the content they index and Scribe is the best way to rectify  all the spelling and grammar mistakes.

The googe scribe is still at Google labs. You can try it and "Submit Product Ideas". Google Scribe uses wonderful auto suggestion. On the left side of the toolbar you will see an option to select multiple suggestions. There is an option to add automatic anchor text for a link. In the new Google Scribe, they will show some suggestions for us to select.

The most wonderful thing about the Google Scribe is that it can be used in our website and we can create content using it. To activate the Google Scribe in your web, you have to  use the Scribe Bookmarklet