Last month of OPW internship

More than 2 months have passed since I started working on GeoIP server and client libraries. The libraries are now ready to use. They provide IP address based Geolocation information.

To use the client library, all you have to do is – create a GeocodeIpclient object and perform a search for Geolocation information. The search function has both synchronous and asynchronous versions –

void geocode_ipclient_search_async  (GeocodeIpclient       *ipclient,
                                     GCancellable          *cancellable,
                                     GAsyncReadyCallback    callback,
                                     gpointer               user_data);

char *geocode_ipclient_search (GeocodeIpclient *ipclient,
                               GError          **error);

To have a better look at how to call these functions visit test-geoip.c

Since we do not have a web service yet, you have to run the GeoIP server at your localhost before you use the client to query for geolocation.

Last week, I’ve added support to update Maxmind city and country databases. Since IP addresses are reassigned, the databases need to be updated. If they are not updated, they loose about 1.5% accuracy each month.

Maxmind update their databases on first Tuesday of every month. So all you need to do is to run the updater (we call it geoip-update) from a cron job. That way you don’t have to worry about downloading the databases manually.
If you are interested to know how accurate the Geolocation data is then visit this link

If you use the Geocode GeoIP libraries now, you will see that the geolocation information based on IP is not as accurate as your google map shows in your smart phone or firefox shows if you enable location sharing from it. That’s because they use a lot of other information e.g. WiFi access point data, cell tower ids etc. to provide you a very accurate location.

The next task that I am working upon now is to increase accuracy of GeoLocation information provided by Geocode GeoIP libraries.

Git is God – what to do if you’ve deleted a commit

You can accidentally delete a commit in many ways – yeah! that’s pretty easy – you just have to do one thing – not pay attention to what you are doing! And boom! you’ve deleted a commit.

In my case, I was rewriting my local commit history before sending a patch. I was using –

git rebase -i

I needed to delete an unnecessary commit but I accidentally deleted the commit on which I was working upon. That was a tight spot. I had 2 files full of changes!
So, now let me enlighten you on the power of Git.
You do a –

git fsck --lost-found

It will show a list of commit ids. In my case I had the commit id (by scrolling upward in the terminal) and it was there in that list of commit ids.
To be sure if that’s the correct commit, you can check it using –

git show 

Then I did –

git cherry-pick <commit_id>

I had multiple such dangling commits. Hence I used cherry-pick. You can get back your work through a lot of other ways – e.g. by using –

git rebase <commit_id>


git merge <commit_id>