Photoblog – Howard Beach

Howard Beach


Howard Beach is an upper middle class neighborhood in the southwestern portion of the New York City borough of Queens. It is bordered in the north by the Belt Parkway and South Conduit Avenue in Ozone Park, in the south by Jamaica Bay in Broad Channel, in the east by 102nd–104th Streets, and in the west by 75th Street. The area’s houses are similar to Bayside and Hollis.

The neighborhood is part of Queens Community District 10, served by Queens Community Board 10. It is home to a large Italian-American population. The ZIP code of Howard Beach is 11414.

– Wikipedia

Ionic – get location permission on android 6

I have a pet project which is building a mobile app using ionic framework. It stopped working on my mobile after upgrading to android 6x. In android 6x, permission was moved from install-time to run-time. This means from now on, users are not granting permissions during installation of apps; rather they’ll be asked to grant permission when they want to use that particular feature in the app. It’s a great idea because if you don’t like to grant one specific permission to an app, you should still be able to use other functionalities.

So, after fixing the issue in my app, I thought it’s worth sharing with others as they may find it useful :). Fixing this issue is pretty simple and straightforward. So, let’s dive in!

Here is how my old codes look like (not exact version though, you got it :p ):

Now we can’t call LocationService.getCoords directly anymore because it’ll fail unless user already granted permission to this app to use location. So let’s ask user to grant permission.

First of all, we need to install a cordova plugin by running the following command in project directory:

cordova plugin add cordova-plugin-android-permissions --save

Then, we gonna write a method, askLocationPermission, for asking permission:

Finally, we can use it just before trying to get coords like:


  • I read somewhere this (can’t find the link) implementation is backward compatible, which makes sense because in older version of Android you’ll be already granted permission during installation (assuming you’ve mentioned locations permission correctly in your app’s manifest).
  • I’ve used promise in the new method. If you like, you can use callback pattern.
  • For list of available permissions, look at this doc.


SparkPost – Control engagement tracking with ActionMailer

In a recent post, I’ve shown how to configure action mailer to send emails through SparkPost. Today, I have faced a situation where it was needed to enable/disable tracking on a specific email. It’s to be noted that, you can globally enable or disable engagement tracking in SMTP. However, if you want to enable tracking (when globally disabled) or disabled tracking (when globally enabled) for a specific email, keep reading.


I assume, you’ve created separate mailer for each type of emails (or for at least the mails you want different tracking behavior for). Follow official doc if you’re not sure what that means or how to do it. Now, let’s configure a mailer to enable engagement tracking. For that I’ve created a HelloMailer.


In the above snippet, we’ve configured welcome email of HelloMailer, hello_mailer.rb, to enable engagement tracking. So links in your template will be automatically converted to trackable links.


  • If email is HTML (text/html), only links will be converted to a tracking URL. It’ll not convert any URLs (because you can use it for, like, anchor text and it won’t make sense to convert)
  • If email is text (text/plain), all URLs in the email will be converted to a tracking URL.
    (See the template, hello.html.erb, to see which URLs will be converted)

If you want to disable engagement tracking in an email, just set the values to false.

headers 'X-MSYS-API': { "options": { "open_tracking": false, "click_tracking": false } }.to_json

It’s that simple :).

photoblog – cooking thai 

Cooking Thai


Thai food ain’t about simplicity. It’s about the juggling of disparate elements to create a harmonious finish. Like a complex musical chord it’s got to have a smooth surface but it doesn’t matter what’s happening underneath. Simplicity isn’t the dictum here, at all. Some westerners think it’s a jumble of flavours, but to a Thai that’s important, it’s the complexity they delight in. –  Wikipedia

Photoblog – BrickHack 2

March 5-6 ignites a weekend devoted to 400 designers and coders sinking 24 hours into learning, building, and creating unique projects. Mentors and industry representatives will also join the fray to lend expertise and share wisdom. The event will take place in RIT’s Gordon Field House for a centralized, communal hacking experience. Expect food, swag, and timeless brick-laden memories.  –

Photoblog – Florida sky

Florida sky

I’ve taken this photo with OnePlus 2 while walking on street in the morning

Florida is the southeasternmost U.S. state, with the Atlantic on one side and the Gulf of Mexico on the other. It has hundreds of miles of beaches. The city of Miami is known for its Latin-American cultural influences and notable arts scene, as well as its nightlife, especially in upscale South Beach. Orlando is famed for theme parks, including Walt Disney World. – Google

Integrate SparkPost in your Rails app

SparkPost (SP) is an advanced email delivery service. For a number of reasons including reputation based sending, high deliverability, scalability etc. SP is trusted by big senders like facebook, twitter, linkedin, pinterest, paypal and you name it.

While SP is suitable for most, SPE (Sparkpost Elite) is for senders who wants to run these services on dedicated boxes. SPE also comes with white gloves support.

Integrating SP with your current application is extremely easy. It’s because:

  • You can start FREE :). Its free plan comes with 10000 100,000 emails per month.
  • Unlike others, there is no manual activation required. You can just open account, verify your domain and start sending immediately.
  • Because SP supports both SMTP and API, integrating with your app is just simple.

If you’re still not sure how to integrate SP in your Rails app, keep reading.

Step 1: Open SP account

  • Visit signup page and complete the form. It’s a very tiny form which takes less a than a minute completeScreenshot 2015-10-13 11.31.50Upon signup, you need to verify your email address. Unless you verify your email, you can’t add sending domain that we’ll do in next step.

Step 2: Add and verify your sending domain

Before we add it, you might ask what is sending domain and why you need this for. Here is the answer from official doc.

A sending domain is a domain that is used to indicate who an email is from via the “From:” header. Using a custom sending domain enables you to control what recipients see as the From value in their email clients. DNS records can be configured for a sending domain, which allows recipient mail servers to authenticate your messages.

Screenshot 2015-10-13 12.24.47

Go to Account -> Sending Domains to add a sending domain (you can leave Linked Tracking Domains option as it is for now). Once you’ve added the domain, you need to verify the domain by adding SPF records. You can also follow the official doc for instructions to verify domain.

Step 3: Generate API Key

SP is really simple in terms of this. If you create an API key with “Send via SMTP”, you can use this same key for SMTP authentication. So simply create an API key from Account -> API & SMTP and select Send via SMTP from API Permission.

Screenshot 2015-10-13 12.36.31

If you’re still not sure, follow this doc for detail instruction.

Step 4: Integrate with Rails

So you’ve done all the required ground jobs. The last part is configuring Rails to use your fresh SP credentials. This part is very simple. All you need is to put the SMTP configuration, ideally, in an initializer script. You can simply copy the following gist in a file inside your Rails app’s initializer directory (config/initializers).

Be sure to replace password and from with appropriate values. Password is the API key that you’ve created with “Send via SMTP” permission in previous step.

Now What?

That’s all. You application now has all the goodness of world’s best email sending platform. Start sending now!  You’ve earned it to yourself :).

Definitely you can separate your development and production configuration and/or move this config to environment variables. Also, you can configure your development environment to raise mail sending exceptions. Set

config.action_mailer.raise_delivery_errors = true 

in config/environments/development.rb.


[disclaimer: I work for SparkPost with awesome people :)]

A two (+12) hours tour to Amazon Fulfillment Center, VA

I’ve reserved this tour about a year ago. I always have a fascination for visiting giant factory like facilities. I think I’ve got this when I witnessed my father as a chief contractor for a giant textile mills in Pagla, Narayanganj.

Initially I planned to visit this with my family until, at very late, I came to know that visitor must be at least 6 years old. My daughter is about 5 years early for that :P, hence my wife couldn’t go too. So, I invited 3 of my other friends and among them 2 could make it in this short notice.

We started on 15th’s very early morning even before we saw the sunlight. It’s more than 6 hours of drive from Brooklyn. We reached there about 30 minutes ahead of scheduled time.

The area closed to the facility is so beautiful. The roads are so clean and solid and natures are really soothing. From the outside we could tell how giant this facility is. Though there were a few signs posted about tour guests parking, it was difficult to locate exact place as several roads were closed and there were no detour signs. So we had to make several back and forth before we found a staff and ask for assistance who removed one of the blocker to the  way to actual tourist parking lot.

When we entered the facility we’ve been welcomed by a few of organizers and we were given badges. Then they took us a to classroom where they’ve given us instructions how the tour will be conducted and also gave us wireless headphones. This was extremely helpful as the whole place is too noisy and we could barely hear anything unless we put the headphone on. The noise basically coming from conveyer belts that were throughout the facility.

Then we’ve taken to different areas of the facility including the inbound area where they process all incoming shipments from FBA sellers, MODs where they store all items in smaller quantity, packing area, labeling and sorting area etc.

I remember, when I saw a packer was very quickly taking boxes for putting items in it I wondered whether he decides those himself that fast or the software tells what size of box required. It’s actually the later. As soon he starts processing order, required size of shipping box is displayed on the screen. Technology is amazing, isn’t it?

Then we’ve been taken to the places where shipping labels are affixed. I thought it’s a manually process until I saw it. After a box is kept on the belt, a shipping label is automatically attached at a later step (identified by order barcode that’s affixed by the packer). However, we saw this process is very error prone and there were 2-3 people who fixes those things manually.

It was very clear that lots of technological magics happen there at all times. However, the importance of manual labor is nevertheless. I was really amazed to see the size of the facility. They also mentioned the combined size of 3 floors is equivalent to 28 football fields.

However, during my short stay there, I’ve got an impression that work condition may be very hard there! I tried to pay attention to a number of people and they looked tired and seemed unhappy. Pardon my judgements if I’m wrong (and I’ll be happy to be wrong here) but I found it aligned when I saw at least two people were sleeping in their car at parking lot. I found only one person, other than the organizers, gave us a positive vibe by giving us smile though many of them noticed us. It may also mean they were very busy and/or their job needs undivided attention! To get a better understand on this, I asked the tour guide how often the workers are allowed to take rest. She replied it’s only twice in their 10 hours shift including their cafeteria time (lunch/dinner/breakfast)! Thanks my load; my job is much easier. Coincidentally it reminded me an article that I read recently about how Amazon pushes its engineers beyond their boundaries.

The tour ended with thank you gift that included a 8oz bottle of water and a mini USB car charger, which interestingly I didn’t find on

Very sadly, we were not allowed to take pictures that actually lost 50% value of the tour, though I respect the fact that it’s their own facility and they have rights to impose any policies. But how something can be a tour if you can’t take a photos?

Overall, unlike my friends, I somewhat enjoyed my tour. I believe the tour can be better in several way including reducing the number of people in each tour so that people can take a closer look. I also want to thank you Amazon to let us visit their facility.

I, however, do not suggest anyone else to take such a long drive for the tour. It’s definitely not worthy. Visit a nearby facility.

Prevent “whenever” creating separate cron job on each deployment

I am using whenever gem for handling cron job in a Ruby on Rails application. It’s fantastic because of it’s very easy DSL to create tasks and schedule it. It will do all the dirty works to update crontab and run your task periodically as per your definition.

However, I ran into one problem that upon each deploy, whenever was creating a separate item in crontab. So when I’ve tried to check cron jobs (crontab -e), I see there are so many tasks.

It was doing this because I didn’t have :application param set in my capistrano settings (deploy.rb). Whenever depends on this name to match the existing names and update it. So all you need is to set application to your deploy.rb file.

set :application, 'your-fancy-app'

That should solve the problem. However, you need to manually cleanup current cronjob as it won’t update the current mess.