Calendar v2?

Calendar web app was something I was working on for about 4 weeks now. This is actually the second version I am trying to release.

After the intitial one, I re alised how “slow” it was due to some serious novice Javascript coding. I spend few weeks refreshing my knowledge in JS, plus kicking myself with Backbone and things are finally looking a-ok.

Hopefully I can get this out before 2011 ends. Can’t wait!

Posted in Anything & Everything | Leave a comment

Small fixes to CodeIgniter, Facebook FQL via Graph with cURL (Phil Sturgeon’s library)

I went absolutely bonkers on trying to get CodeIgniter with Facebook Graph API via cURL.

Firstly, the problem here was the fact that everything was indeed working fine. Then when I tested my code again, things started breaking. Here’s my scenario.

I am using CodeIgniter 2.1.0 (the latest one) and I am trying to get the list of all the albums I have on Facebook via Facebook Graph API. In particular, I am running FQL to get these data, since I only need a few data fields.

In addition, I am also using Phil Sturgeon’s cURL library, so I don’t have to worry about all the nitty gritty details.

Here are TWO fixes I had to implement in my code to get things rolling.

  1. Specify “http_build_query” in Curl.php to handle ampersand character correctly.  According to the PHP site, this is what it states.

    As noted before, with php5.3 the separator is & on some servers it seems. Normally if posting to another php5.3 machine this will not be a problem. But if you post to a tomcat java server or something else the & might not be handled properly. To overcome this specify: http_build_query($array, ”, ‘&’).

    Looks like when interacting with Facebook Graph, you need to specify this.

  2. Specify options in cURL – Previously, I called a “simple_get( URL, array(‘q’ => my_fql, ‘access_token’ => my_access_token))”. When talking to FB, you need to specify the following options

    $this->curl->option(CURLOPT_SSL_VERIFYPEER, false);

    A little bit strange, since I didn’t have to do this before. But if Facebook is tweaking their systems all the time, which I imagine they do, we just need to adapt.

Hope that alleviates pain for some people who are doing similar things as me.

Posted in Coding, Question everything | 2 Comments

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 , , , | 2 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