Hello VPS!

I wouldn’t call myself much of a Linux admin, but I’m glad to say I have finally managed to set up my own VPS and have begun my process of transferring all my sites. It’s a big sigh of relief, since the shared hosting gave me too many headaches (it’s supposed to be the other way around right?). Anyway, here’s to my first post on my blog from my VPS.

Posted in Anything & Everything | Leave a comment

10KB Challenge – BILLIE – Hassle free bill splitting

Spent about 2 days trying to get this 10KB app up and running. I called it Billie and it’s a simple little tool that helps you split many bills into an evenly distributed cost shared by a number of people. Check it out and it will be self-explanatory.

What I did realise is that 10KB wasn’t as challenging as I expected originally. It’s possibly because of all the different CDNs available and you can load different media files from various locations other than your own domain. It would’ve been a different story if it was purely based on HTML5, CSS3 and Javascript (without jQuery!). Then again, where is the Web 2.0 component side of it?

All in all, it was another app I wanted to publish and get it out there. Something that has been on my mind for far too long.

Posted in Ideas! | Tagged , , | Leave a comment

What’s Happenic?

It took me awhile, but after tweaking and changing and updating and all that juggling of ideas and thoughts, I decided that this would finally be my MVP (minimum viable product) for Happenic.com. So without further delays, I want to launch “Happenic” – http://www.happenic.com.

Happenic is a no-frills, no-registration-required, use-straight-out-of-the-site tool, that aggregates events around your major cities. Currently, there are a few major sites that list events, which are

  • Eventbrite
  • Eventful
  • Upcoming
  • Meetup

Of course, there are a few more, but I consider above four sites together would probably be the nearly-complete event listing you can find.

But who has the time to go through them all? And each site has its own niche categories and may not provide you a quick overview of what is happening. And surely you don’t want to spend your time sifting through duplicate events. The motivations for pulling data together are many. So Happenic does that quite happily. Right now, I am focusing on Australia, but depending on the requests, I’ll try to launch it in different cities too.

What I love, is the fact that it’s something I desperately needed, because I didn’t want to spend so much time looking through all the sites. So I finally got my own tool to accomplish the task! How cool!

Posted in Coding, Ideas! | Tagged | Leave a comment

Fix on TipTip jQuery plugin

Drew Wilson’s TipTip jQuery plugin is one of the simplest and therefore the best tooltip plugins for jQuery I have come across. While, there are a number of tooltip packages, and some of them are quite feature-heavy, I was on the lookout for a very simple, nice looking tip and well TipTip is it!

However, while using it, I came across two problems, which were both to do with using TipTip in multiple places within a single page. The first was the “maxWidth” option, which seemed to take only the very firstly-defined option, while ignoring others. Second was sometimes (and rather strangely), TipTip thinks there is an empty content and displays an empty box, while rendering the content behind. So you would see a white shadow in the middle of your tooltip content.

Well, I couldn’t help it so I forked this plugin, cut out some code and put it up on GitHub. Hope this would help others who are trying to use TipTip!

Posted in Coding, Question everything | Tagged , , , | 3 Comments

Calculating distance between a pair of latitudes/longitudes (The Great Circle problem)

This is a rather popular question and a standard answer is provided, but I thought I’d better copy it down somewhere in case I want to refer to it again. Google has a nice and quick explanation of how to calculate the distance between two geolocational points. Surely, it’ll come in handy some time.

Finding locations nearby with MySQL

To find locations in our markers table that are within a certain radius distance of a given latitude/longitude, you can use a SELECT statement based on the Haversine formula. The Haversine formula is used generally for computing great-circle distances between two pairs of coordinates on a sphere. An in-depth mathemetical explanation is given by Wikipedia and a good discussion of the formula as it relates to programming is on Movable Type’s site.

Here’s the SQL statement that will find the closest 20 locations that are within a radius of 25 miles to the 37, -122 coordinate. It calculates the distance based on the latitude/longitude of that row and the target latitude/longitude, and then asks for only rows where the distance value is less than 25, orders the whole query by distance, and limits it to 20 results. To search by kilometers instead of miles, replace 3959 with 6371.

SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) )
AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
Posted in Coding | Tagged , , | Leave a comment

Mixing PHP session with jQuery asynchronous AJAX

I am currently using a mix of PHP, jQuery and MySQL to create a mid-sized application. One of the main things involved is in utilizing PHP session variables that store different values that are used throughout the app. It’s especially handy in CodeIgniter because it takes a good care of your variables while hiding all the details behind.

Today, however, I ran into a nasty little problem, where I was calling a PHP function via jQuery “get” call, which inadvertently sets a session variable, only to realise a little later that the session variable has disappeared. What happened? Here’s a snippet of the code.

$.get(url_1, {params}, function(data) {});

$get(url_2, {params}, function (data) {});

Now imagine, on the PHP side, url_1 and url_2 both set session variables.

function url_1() {

set_session_variable(“var_1″, “hello”);

}

function url_2() {

set_session_variable(“var_2″, “world”);

}

It looks ok from here, but if you understand the nature of JavaScript, which is “asynchronous”, the two URLs will be called at the same time (or very very close together). When this was happening in my app, the two session variables were being set at the exactly same time, therefore one overriding the other. JavaScript is great when you are indeed looking for a asynchronous call, but from time to time, when you have to control the flow, you really have to watch out!

Posted in Coding, Ideas! | Tagged , , | Leave a comment