Author: hasin

I would love to be a baby sitter

Well, it may sound funny but this is what I want to be after 6 years. I am quite planned about my future and I will definitely retire from my regular web app dev job after 6 years. Beside this I love kids, love talking to them and love to see them growing up 😀

so I am going to be a baby sitter after 6 yrs and I am sure, I will do good 😀

WorldTimeEngine – How about making your own in PHP?

I recently came by this site WorldTimeEngine where users can search the local time of any place using the name, street address or just latitude and longitude. Since that time I was thinking how easily you can make your own. As long there are some good people over there (For Geocoding API) – its a not a big deal, you know? Lets have a look at the following PHP code.


<?
$place = "Bucharest";

$geodata = getGeoCode($place);
print_r($geodata);
echo getTime($geodata['lat'],$geodata['lng']);

function getTime($lat, $lng)
{
$url = "http://ws.geonames.org/timezone?lat={$lat}&lng={$lng}";
$timedata = file_get_contents($url);
$sxml = simplexml_load_string($timedata);
return $sxml->timezone->time;
}
function getGeoCode($address)
{
$_url = 'http://api.local.yahoo.com/MapsService/V1/geocode';
$_url .= sprintf('?appid=%s&location=%s',"orchid_geocode",rawurlencode($address));
$_result = false;
if($_result = file_get_contents($_url)) {
preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match);
$lng = $_match[2];
$lat = $_match[1];
return array("lat"=>$lat,"lng"=>$lng,"address"=>$address);
}
else
return false;
}
?>

Changing the variable “$place” to “Bucharest”,”Dhaka”, “Toronto” and “Oslo” gives me the following result


Array
(
[lat] => 44.434200
[lng] => 26.102955
[address] => Bucharest
)
2008-03-01 08:41

Array
(
[lat] => 23.709801
[lng] => 90.407112
[address] => Dhaka
)
2008-03-01 12:42

Array
(
[lat] => 43.648565
[lng] => -79.385329
[address] => Toronto
)
2008-03-01 01:42

Array
(
[lat] => 59.912280
[lng] => 10.749980
[address] => Oslo
)
2008-03-01 07:43

Nice, Huh?

29th Feb, 2012

What will happen this day in 2012?

Afif will be almost 6yrs old
His sister will be 3 yrs old
I will code in PHP10 and Python 5
I will still be young like today
I will hold a MySQL DBA Cert
I will be writing a book on Python
I will be having a car
No one in my family will be using windows anymore
I will write a blog post titled “29th Feb, 2016”
I will still be singing “Like a rolling stone”

And Finally

I will be preparing more for the self retirement in 2015

Getting Dell BCM4328 Wifi Card Working on Ubuntu 7.10

After trying,searching and crying for more than one month, I finally get it working today in my laptop (Dell Inspiron 6400) 🙂 – I am one of the happiest ever in this world right now :D. here’s how to. All the credit goes to “kayvortex

Model of my wifi card is “Broadcom BCM4328 802.11a/b/g/n (rev 01)”

Steps

1. Install Ndiswrapper Common and Ndiswrapper Utils (You can do it using synaptic)
2. Download The Driver from ftp://ftp.dell.com/network/R151517.EXE and unzip it somewhere. You will see a folder named DRIVER
3. Execute the following commands


sudo ndiswrapper -i /download_directory/DRIVER/bcmwl5.inf
sudo ndiswrapper -l
sudo modprobe ndiswrapper

4. Then, set ndiswrapper to load on startup:

sudo ndiswrapper -m
gksudo gedit /etc/modules

and add the following module to the list


ndiswrapper

5. Restart (This is a must)

Now you can use Fn+F2 to turn on your wifi 😀 )

Virutal Interview, Are you interested?

I can do one thing to help you out there 🙂 – if you are confident on PHP, JS and web application development – or if you want to see how a real interview actually takes place, I can take your interview for 30 minutes. You can just hide your name, designations if you want. I wouldn’t ask your real name or any private info for sure. I can send you the report right after your interview and using that you can understand where do you lack.

If you are interested for a 30 minutes interview over messenger – drop me a mail to [email protected]. Please note that you can hide your id for sure. I am sure it will help you to upgrade yourself (myself too :D)

On the way back to Dhaka – Seminar on "Current Job Trends"

Right now I am in the train on the way back to Dhaka. Got some free minutes in hand to write a post focusing things happened this week.

Last couple of days were simply awesome. I came to Rajshahi to present a seminar on “Current Job Trends” in “Rajshahi University of Engineering and Technology (RUET)” to help students to get a basic overview of current job market. Beside that I also focussed to the thngs they should be prepared before going to interview. To describe the overall feedback – it was amazing. I was surprised by their engagement and enthusiasm. It seems like they were waiting for such a seminar for a long time. Special thanks goes to faculty of computer science and engineering for arranging that. Professor Dr. Shahiduzzaman helped a lot to make it happen. Definitely thanks also goes to Sarwar Sattar (Stalin) and Murad, faculty of the department for their incredible help. Rana (05 CSE) – thank you too.

Seminar

You can download the slides from here http://javapark.net/hasin/RecentJobTrends.pdf.tar.gz

The seminar went great (well, I am saying ‘great’ based on the feedback I’ve got) – I will soon post some pictures of this seminar. After the end of this seminar, Professor Dr. Shahiduzzaman invited me to attend the farewell program of 03 batch. I feel honored to be invited in such a program. And I didnt miss the chance.

Beside these official programs, I also went to Naogaon to visit the house of my in-laws parents. The reception was beyond my imagination. I always like this cordiality of village peoples. Thats why I want to spend my life after 35 in such a place.

I will try to arrange such seminars in different universities to increase the awareness.

Unexpected return value from Facebook FQL.query via PHP REST Lib

While working with FQL I suddenly found a bug in one of our applications. The method which we used to count number of friends of a specific user who has added that application was returning 1 when there is no friend actually installed itāĨ¤ Using the following FQL you can easily find that. (FQL doesn’t support “count” – so you cant use it)

SELECT uid FROM user WHERE has_added_app = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = {$userid})

The PHP code may look like the following one

function getTotalFriends($userid)
{
global $facebook, $mysql;
$Users = $facebook->api_client->fql_query("SELECT uid FROM user WHERE has_added_app = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = {$userid})");
$NumberOfUsers = count(trim($Users));
return $NumberOfUsers;
}

So what would you expect when there is no friend who has added this application? Definitely the FQL query should return an empty array. So that counting elements of that array tells you that you have “0” friends. But actually it returns a white space. What’s the difference between an empty array and a white space? l

count(array()) returns 0
count (” “) returns 1

So even when you dont have any friends, your method actually returns you “1”. The return result is not expected. What does your common sense says? Either the method should return false or an empty array. Not a white space.

Here’s the correction


function getTotalFriends($userid)
{
global $facebook, $mysql;
$Users = $facebook->api_client->fql_query("SELECT uid FROM user WHERE has_added_app = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = {$userid})");
$NumberOfUsers = is_array($Users)?count($Users):0;
return $NumberOfUsers;
}

āωāχāĻ¨ā§āĻĄā§‹āϜ āĻ›āĻžā§œāĻž āĻāĻ• āĻŽāĻžāϏ+

āφāĻŽāĻŋ āĻāχ āĻŦāĻ›āϰ⧇āϰ āĻāĻ•āĻĻāĻŽ āĻļ⧁āϰ⧁āϤ⧇ āφāĻŽāĻžāϰ āĻ˛ā§āϝāĻžāĻĒāϟāĻĒ āĻĨ⧇āϕ⧇ āωāχāĻ¨ā§āĻĄā§‹āĻœā§‡āϰ āĻļ⧇āώ āϚāĻŋāĻšā§āύāϟāĻŋāĻ“ āĻŽā§āϛ⧇ āĻĢ⧇āϞ⧇āĻ›āĻŋāĨ¤ āĻŦ⧇āĻļ āĻ…āύ⧇āĻ•āĻĻāĻŋāύ āĻŽā§āϝāĻžāύāĻĄā§āϰāĻŋāĻ­āĻž āĻŦā§āϝāĻŦ‌āĻšāĻžāϰ āĻ•āϰāĻžāϰ āĻĒāϰ āĻŽāύ⧇ āĻšāϞ āĻ…āĻ¨ā§āϝāĻ•āĻŋāϛ⧁ āĻŸā§āϰāĻžāχ āĻ•āϰ⧇ āĻĻ⧇āĻ–āĻž āϝ⧇āϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ āωāĻŦ⧁āĻ¨ā§āϤ⧁ āχāĻ¨ā§āϏāϟāϞ āĻ•āϰ⧇ āφāĻŽāĻŋ āϰ⧀āϤāĻŋāĻŽāϤ āĻŽā§āĻ—ā§āϧāĨ¤āĻĻāĻžāϰ⧁āύ āχāωāϜāĻžāϰ āĻĢā§āϰ⧇āĻ¨ā§āĻĄāϞāĻŋ āχāĻ¨ā§āϟāĻžāϰāĻĢ⧇āϏ, āĻĄā§‡āĻŦāĻŋ⧟āĻžāύ⧇āϰ āĻļāĻ•ā§āϤāĻŋāĻļāĻžāϞ⧀ āĻĒā§āϝāĻžāϕ⧇āϜ āĻŽā§āϝāĻžāύ⧇āϜāĻžāϰ āĻāĻŦāĻ‚ āĻĻāĻžāϰ⧁āύ āϏāĻŦ āĻ“āĻĒ⧇āύ āϏ⧋āĻ°ā§āϏ (āĻāĻŦāĻ‚ āĻ•ā§āϞ⧋āϜ āϏ⧋āĻ°ā§āϏāĻĄ) āĻĒā§āϝāĻžāϕ⧇āĻœā§‡āϰ āĻŦāĻĻ⧌āϞāϤ⧇ āĻāĻ•āĻŦāĻžāϰ⧇āϰ āϜāĻ¨ā§āϝāĻ“ āĻŽāύ⧇āχ ‌āĻšā§ŸāύāĻŋ āϝ⧇ āωāχāĻ¨ā§āĻĄā§‹āĻœā§‡ āφāϰ āĻĢ⧇āϰāĻžāϰ āĻĻāϰāĻ•āĻžāϰ āφāϛ⧇āĨ¤ āĻāĻ›āĻžā§œāĻž āωāχāĻ¨ā§āĻĄā§‹āĻœā§‡ āφāĻŽāĻžāϰ āϖ⧁āĻŦāχ āĻĢ⧇āĻ­āĻžāϰāĻŋāϟ āĻ•ā§Ÿā§‡āĻ•āϟāĻŋ āϏāĻĢāϟāĻ“ā§Ÿā§āϝāĻžāϰ āĻ›āĻŋāϞ (āϏ⧇āϗ⧁āϞ⧋āĻ“ āĻĢā§āϰāĻŋ) āϝ⧇āϗ⧁āϞ⧋āϰ āϞāĻŋāύāĻžāĻ•ā§āϏ āĻĒā§‹āĻ°ā§āϟ āφāĻŽāĻŋ āĻĒāĻžāχāύāĻŋ – āϤāĻžāχ āĻ“ā§ŸāĻžāχāύ āχāĻ¨ā§āϏāϟāϞ āĻ•āϰ⧇ āύāĻŋā§Ÿā§‡āĻ›āĻŋ āϏ⧇āϗ⧁āϞ⧋ āϚāĻžāϞāĻžāύ⧋āϰ āϜāĻ¨ā§āϝāĨ¤ āύāĻŋāĻšā§‡ āφāĻŽāĻžāϰ āĻĢ⧇āĻ­āĻžāϰāĻŋāϟ āĻĒā§āϝāĻžāϕ⧇āϜ āϗ⧁āϞ⧋āϰ āĻāĻ•āϟāĻž āϞāĻŋāĻ¸ā§āϟ āĻ•āϰāϞāĻžāĻŽ – āĻ•āĻžāϰ⧋ āĻ•āĻžāĻœā§‡ āϞāĻžāĻ—āϤ⧇āĻ“ āĻĒāĻžāϰ⧇āĨ¤

āĻĢāĻŸā§‹āĻļāĻĒ⧇āϰ āĻŦāĻŋāĻ•āĻ˛ā§āĻĒ â€ŒāĻšāĻŋāϏ⧇āĻŦ⧇ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻ›āĻŋ āϜāĻŋāĻŽā§āĻĒāĻļāĻĒ
āχāϞāĻžāĻ¸ā§āĻŸā§āϰ⧇āϟāϰ⧇āϰ āĻŦāĻŋāĻ•āĻ˛ā§āĻĒ āχāĻ‚āĻ•āĻ¸ā§āϕ⧇āĻĒ
āϏāĻŋāĻĄāĻŋ/āĻĄāĻŋāĻ­āĻŋāĻĄāĻŋ āϰāĻžāχāϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āϕ⧇āĻĨā§āϰāĻŋāĻŦāĻŋ (k3b)
āĻ“āĻĒ⧇āύ āĻ…āĻĢāĻŋāϏ – āφāĻŽāĻžāϰ āĻ“ā§ŸāĻžāĻ°ā§āĻĄ āĻĒā§āϰāϏ⧇āϏāĻŋāĻ‚, āĻ¸ā§āĻĒā§āϰ⧇āĻĄāĻļāĻŋāϟ āĻāĻŦāĻ‚ āĻĒā§āϰ⧇āĻœā§‡āĻ¨ā§āĻŸā§‡āĻļāύ āϤ⧈āϰ⧀āϰ āĻ•āĻžāĻœā§‡
āĻĢāĻžāχāϞāϜāĻŋāϞāĻž āφāĻŽāĻžāϰ āĻ­āĻžāϞ āϞāĻžāϗ⧇ āύāĻž – āϤāĻžāχ āĻāϏāĻāĻĢāϟāĻŋāĻĒāĻŋāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻŋ āωāχāύāĻāϏāϏāĻŋāĻĒāĻŋ (WinSCP) āĻāĻŦāĻ‚ āϏāĻžāϧāĻžāϰāύ āĻāĻĢāϟāĻŋāĻĒāĻŋāϰ āϜāĻ¨ā§āϝ āĻŸā§‹āϟāĻžāϞ āĻ•āĻŽāĻžāĻ¨ā§āĻĄāĻžāϰ
āĻ­āĻŋāĻĄāĻŋāĻ“ āĻĻ⧇āĻ–āĻžāϰ āĻ•āĻžāĻœā§‡ āĻ­āĻŋāĻāϞāϏāĻŋ āĻĒā§āĻ˛ā§‡ā§ŸāĻžāϰ
āĻ—āĻžāύ āĻļā§‹āύāĻžāϰ āϜāĻ¨ā§āϝ āϰāĻŋāĻĻāĻŽāĻŦāĻ•ā§āϏ
āĻšā§āϝāĻžāϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻĒāĻŋāϜāĻŋāύ
āĻŦā§āϰāĻžāωāϜāĻžāϰ ‌āĻšāĻŋāϏ⧇āĻŦ⧇ āĻ•āĻŋ āχāωāϜ āĻ•āϰāĻŋ āϤāĻž āĻ•āĻŋ āφāĻŦāĻžāϰ āĻŦāϞāĻž āϞāĻžāĻ—āĻŦ⧇? āĻ…āĻŦāĻļā§āϝāχ āĻĢāĻžā§ŸāĻžāϰāĻĢāĻ•ā§āϏ āĻāĻŦāĻ‚ āĻ…āĻĒ⧇āϰāĻž
āĻĄāĻžāωāύāϞ⧋āĻĄ āĻ…ā§āϝāĻžāĻ•āϏ⧇āϞāĻžāϰ⧇āϟāϰ ‌āĻšāĻŋāϏ⧇āĻŦ⧇ āĻŽāĻžāĻ˛ā§āϟāĻŋāϗ⧇āϟ (Multiget)
āϕ⧋āĻĄāϞ⧇āĻ–āĻžāϰ āϜāĻ¨ā§āϝ āϜāĻŋāύāĻŋ (Geany), āĻœā§‡āĻ¨ā§āĻĄ āĻ¸ā§āϟ⧁āĻĄāĻŋāĻ“, āύ⧇āϟāĻŦāĻŋāύāϏ āĻāĻŦāĻ‚ āĻāϏāĻĒāĻŋāϕ⧇āϟ āφāχāĻĄāĻŋāχ (SPket IDE)
āχāĻ‚āϞāĻŋāĻļ āϟ⧁ āχāĻ‚āϞāĻŋāĻļ āĻĄāĻŋāĻ•āĻļāύāĻžāϰ⧀āϰ āϜāĻ¨ā§āϝ āχāωāϜ āĻ•āϰāĻŋ āϜāĻžāϞāĻŋāĻ‚āĻ—ā§‹ (Jalingo)
āĻĒ⧇āϜāĻŽā§‡āĻ•āĻžāϰ ‌āĻšāĻŋāϏ⧇āĻŦ⧇ āĻ¸ā§āĻ•ā§āϰāĻžāχāĻŦāĻžāϏ
āϏāĻŋāĻāĻ‡â€ŒāϚāĻāĻŽ (CHM) āĻĢāĻžāχāϞ āĻĒ⧜āĻžāϰ āĻ•āĻžāĻœā§‡ āĻāĻ•ā§āϏāϏāĻŋāĻāχāϚāĻāĻŽ (xCHM)
āĻĒāĻŋāĻĄāĻŋāĻāĻĢ āĻĢāĻžāχāϞ āĻĒ⧜āĻžāϰ āϜāĻ¨ā§āϝ āĻāĻ­āĻŋāĻ¨ā§āϏ (Evince)
āĻŽāĻžāχāĻāϏāĻ•āĻŋāωāĻāϞ āϜāĻŋāχāωāφāχ āĻĢā§āϰāĻ¨ā§āϟāĻāĻ¨ā§āĻĄ ‌āĻšāĻŋāϏ⧇āĻŦ⧇ āĻāϏāĻ•āĻŋāωāĻāϞ āĻ‡ā§Ÿā§‹āĻ— (SQLYog)

āφāϰ āĻ•āĻ–āύ⧋āχ āωāχāĻ¨ā§āĻĄā§‹āĻœā§‡ āĻĢ⧇āϰāĻž āĻšāĻŦ⧇ āύāĻž āφāĻŽāĻžāϰ 😀 – āφāĻĢāĻŋāĻĢ (āφāĻŽāĻžāϰ āϛ⧇āϞ⧇) āĻ“ āϛ⧋āϟāĻŦ⧇āϞāĻž āĻĨ⧇āϕ⧇āχ āϞāĻŋāύāĻžāĻ•ā§āϏ⧇āχ āĻ•āĻžāϜ āĻ•āϰāĻŦ⧇ āχāύāĻļāĻžāĻ˛ā§āϞāĻžāĻšāĨ¤

Hacking SlideShare.net using PHP

Duh! you really believed that tricky title? come on!

But hey, wait. Here’s something I’ve found for you!

I am a big fan of slideshare becoz of their fantastic presentation sharing service and also the display. but it also hurts me when I can’t download some of these awesome slides available there for my offline reading. So I just spent some time today analyzing the HTTP requests made by the player available in slideshare using LiveHTTPHeader extension and found a way to download any presentation you want! There are many slides available in slideshare where you see that “Download not available” – But as long you have some knowledge on web-scrapping, that doesn’t matter at all.

Look at the following PHP code which gives you a list of URLs of the slides from any slideshow in slideshare.net – whether the presentation is available to download or not! for example the presentation on “Ajax and PHP” by John Coggeshall is not available to download. The url is of that presentation is http://www.slideshare.net/coogle/ajax-and-php


<?php
$slideshowUrl="http://www.slideshare.net/coogle/ajax-and-php";
$slideshowPageContent = file_get_contents($slideshowUrl);
$pattern = "~doc=([\w-]+)~";
preg_match($pattern,$slideshowPageContent,$matches);
$xmlurl = "http://s3.amazonaws.com/slideshare/{$matches[1]}.xml";


$sxml = simplexml_load_file($xmlurl);

foreach ($sxml->Slide as $slide)
echo $slide['Src']."<br />";
?>

The output will be something like this

https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-1.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-2.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-3.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-4.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-5.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-6.swf
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-7.swf
..........
https://s3.amazonaws.com:443/slideshare/ajax-and-php-1194421981517706-1-slide-40.swf

I am sure you are going to love me! 😀