Tuesday, March 10, 2015

Facebook: All time ranges must be midnights - Not every day is like another, some days are 23h and some are 25h long

Facebook has funny thing about their API. They require timestamps used in their report to be on midnight boundary in your local timezone.

Originally I wrote this code:


facebook_time = DateTime.parse(@run_date.to_s).utc.in_time_zone('America/Los_Angeles').midnight.to_i
time_interval="{time_start:#{facebook_time}, time_stop:#{facebook_time+24*3600}}"

That worked great until daylight savings kicked in, and failed with "All time ranges must be midnights", so after a bit of debugging I changed it to this one:

facebook_time = DateTime.parse(@run_date.to_s).utc.in_time_zone('US/Pacific-New').midnight.to_i
facebook_time_end = DateTime.parse((@run_date+1).to_s).utc.in_time_zone('US/Pacific-New').midnight.to_i
time_interval="{time_start:#{facebook_time}, time_stop:#{facebook_time_end}}"
I hope this will help someone spend less time debugging.

Friday, February 20, 2015

Creating Users and Databases

It is tedious to create database. Well, not really hard, just annoying.

While 3 lines of code to create database, create user and grant user privileges to the database are not hard to write, one needs to remember correct syntax and to place same text 2-3 times.

To mitigate this issue, I created a tiny template to help me with it. It is available at:


Or embedded here for your convenience:

Sunday, January 4, 2015

Did you ever wanted to know when a webpage changed?

There is a new web service - WebFollower - what it does is a simple simple, but still important task.
Here is how it works - you sign-up with your Facebook account and go to the dashboard.
On the dashboard you add URLs you'd like to monitor and web follower crawler checks if page has changed. If it didn't than nothing happens and WebFollower's crawler checks it again later. If it did change WebFollower sends you an email notifying you that page changed. If you want to be notified of change when page changes again, you'll need to re-enable it on the dashboard.

That's it - a simple and hopefully useful service.