Home Blogs General
General


How to find distance between two places using longitude and latitude PDF Print E-mail
Written by Kuldip Pabla   
Saturday, 17 April 2010 21:12

Sometimes we need to find out list of places that are within a certain radius from a center place where coordinates of the places are saved in the database as latitude (lat float(10,6)) & longitude (lng float(10,6)).

There are two possible options:

1) Loop through all the places in the databases, find the distance from the center point and keep the places that have distance less or equal to the radius.

2) Define an sql function to find the distance between two places, and select the places having distance less or equal to the radius.

Obviously the second option is way better and efficient than the first one.  Here is how you do it

DELIMITER $$
DROP FUNCTION IF EXISTS `getDistance`$$   // drop any previously defined function
CREATE FUNCTION `getDistance`(lat1 float(10,6),lng1 float(10,6), c1 VARCHAR(120), c2 VARCHAR(30)) 
RETURNS VARCHAR(120) 
BEGIN 
DECLARE lng2, lat2, distance float(10,6); 
select CAST(c1 as DECIMAL(10,6)) into lat2; 
select CAST(c2 as DECIMAL(10,6)) into lng2; 
select ((ACOS(SIN(lat1 * PI() / 180) * SIN(lat2 * PI() / 180) + COS(lat1 * PI() / 180) * COS(lat2 * PI() / 180) * COS((lng1 - lng2) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) into distance; 
RETURN distance; 
END$$
DELIMITER ;

 

It defines a MySQL function that you can use from within your code or using SQL query

USAGE: select id, email from custs where getDistance (lat, lng, x, y) <= radius;

where:

lat: is a column in your database representing latitude of a place

lng: is a column in your database representing longitude of a place

x: is the latitude of a central position, say "36.288757"

y: is the longitude of a central position, say "111.804558"

radius: is the radius within which you want to find places.

Last Updated on Sunday, 18 April 2010 01:37
 
Is FaceBook Hacked? PDF Print E-mail
Written by Kuldip Pabla   
Monday, 04 January 2010 16:35

Happy New Year to all of you!

No, this is not a hack or a mass message spread by Facebook. These are my own wishes for you from the bottom of the heart. I wish you that you never get bombarded with spams and hacks.

On the very first day of this year, I got greeted by a message from Facebook:

"hey there I was just talking to Aditya and they asked me to show you this AmericanBizNews . org"

Soon, I knew it was some kind of virus or FB hack that is mas contacting FB members. However, I did not care much about it. I never knew anyone named Aditya in my whole life.

To my surprise, I had better greetings waiting in my INBOX this morning when I woke up. These were sort of "angered" messages from my own friends who had received a similar message. This time it was from me - I mean someone acting like me. You know what I mean.

As the FB is growing larger than image, it has been loosing control over everything. A few weeks ago, I had blogged about how CPU consuming their service had become - fortunately they fixed it. And now, it is the hackers abusing the loop holes in the FB APIs. I wish, in this new year (not new decade), FB would take controls of their activities and fix the problems they have been letting others create for them.

Sometimes, I wonder if this is the beginning of Social Media Viruses.I wonder is should I still be moving my contents and my applications to the CLOUD. In my humble opinion, cloud isn't safe as of today. Yes, it can me made safe, but that would add its cost and time.

This also reminds me that I should stay with safe harbors like Solaris and Linux which are rarely affected by such viruses. Also, I think, it is time for private social media rather than open social media.

Happy Safe Surfing!

 
Google Search Engine in $250 PDF Print E-mail
Written by Kuldip Pabla   
Friday, 20 November 2009 04:36

Google Search Engine in $250! Yes, that is correct. no Millions and no Billions.

Is there someone who would develop a clone of Google Search Engine in $250? Yes, do not get surprised! While surfing around, I came across this requirement on oDesk that requires someone to develop a Google like Search Engine for $250.

Well, I'll be ready to pay 10 times or even more to get a Google Search Engine kind of functionality.

And that is not it, it needs to be delivered by sometime in January of 2010 guys. What th eheck Google was doing all these years in developing a search engine, when someone can do it in less than 3 months?

 

 
FREE Workshop: The Six Key Characteristics of Successful Entrepreneurs PDF Print E-mail
Written by Kuldip Pabla   
Friday, 20 November 2009 00:02

"Most successful entrepreneurs figure out how to grow their businesses in ways that you wouldn't find in a business text book. Although there is not one single formula to become a successful entrepreneur, Silver Lining believes that there are six key characteristics that help predict success.

New York entrepreneur network is hosting a free workshop. Here is an exerpt of the event announcement. For more details or go RSVP for this free event, go to http://www.ny-entrepreneur-network.com/calendar/11907025/

 
Moto Droid v RIM Blackberry PDF Print E-mail
Written by Kuldip Pabla   
Wednesday, 04 November 2009 17:52

Motorola, Google and Verizon launched Droid a few days ago. At the very first impression, the Droid has been winning the consumer and the analyst appreciation. It has many coop features that a smart phone competing with iPhone should have. And then it has the hype of Android in it. So, the question is, what does it mean to RIM's Blackberry, blackberry users and blackberry developers? IMO, this will have a great impact on the market of RIM handsets and hence an impact on Blackberry apps and developers.

Here is my reasoning. There are just two main wireless carriers in the US: AT&T and Verizon. AT&T has been widely promoting iPhone as its smart phone. Why wouldn't it! With its well know user experience, sleekness and the app store, iPhone has been scoring big as compared to its competition. The iPhone App Store has many many applications that a user would need on a smart phone. With their improved email functionality, even the corporations have been going for the phone. This leaves a little room for any other smart phone on AT&T network. And that other smart phone happens to be Blackberry.

On the contrary, Verizon had only one star to promote and advertise until droid came into the race. And that was RIM's Blackberry. With Verizon's reach and customer base, the market of Blackberry was on the rise in the smart phone category. I would say that was the only smart phone sold by Verizon, there was no #2. And as you may know, Blackberry has traditionally been liked by enterprises due to its enterprise friendly features.

Now enters Droid in the market. As of today, Droid has been the #1 promotional item for Verizon. What does that mean? It means, it cuts into Verizon's budget for Blackberry. Isn't it? And Blackberry has become #2 for Verizon - so it slipped in the ranking. This will lead to slow down in the sale of Blackberry in the short term.

In the longer run, it would depend on the success of droid. If the Droid is able to live up its hype, then Blackberry has long term problems, unless and until RIM launches a more powerful, user friendly handset that outshines Droid. On the other hand if Droid dies its own hype, the Blackberry will bounce back. So, it all depends on how Droid is going to perform and live up to its early hype.

Please note this is my humble opinion that I am sharing via this blog. It has too many ifs and buts and no certainity.

Last Updated on Wednesday, 04 November 2009 18:23
 
«StartPrev123NextEnd»

Page 1 of 3
Copyright © 2010 KSPTech Inc.. All Rights Reserved.
 

Sponsors