mitmproxy for troubleshooting

Recently at work, we had an issue where a redirection to a certain site was failing (404) on Safari but not in any of the other major browsers. While Safari doesn’t have as robust a developer tool as Chrome, it still shows Network calls but not with sufficient details. In fact, it looks like it consolidates the 3XX redirects into a single request.

This was a good time to pull out mitmproxy. I hadn’t used it in a while and had to look up how to configure the browser to use mitmproxy again.

The next step was to intercept the requests for the particular domain and sure enough the problem was revealed. There was a tab character that was being appended to the end of the URL and Safari seemed to be encoding that and trying to visit the URL which resulted in the 404. Other browsers just ignored the trailing white space and continued on.


Solution: Unable to Ctrl+Drag an action from an Object to an existing method

I was following a CodePath tutorial on creating a Tip Calculator. The author is using an earlier version of Xcode while I am using Xcode 8.2. The problem I faced is that while the author was able to drag and associate an object’s action with an existing method (at around the 31 minute mark), I was unable to do so and it was only prompting me to create a new action. I scoured the web for answers and most seemed to suggest ensuring that the `ViewController` class was correctly named in the StoryBoard. Some suggested clearing the cache and restarting the OS but none of those solutions worked.

I finally checked whether Xcode stopped supporting this feature in 8.2 but the Xcode docs suggested that this is supported. Then I realized that all the examples had the function parameter type as `AnyObject` whereas mine had `Any`. I changed it to `AnyObject` and, voilà, I was able to associate the action with the existing method. It looks like the Create Action prompt defaults to a type of `Any` in Xcode 8.2 and I don’t see an option of `AnyObject` although it can be typed in. So, there you have it. If this helped you, I’d love to hear it in the comments.


2016 Summary

One of my New Year resolutions was to complete a full marathon and despite some breaks due to vacations, I was most proud of the fact that I completed the SF Marathon in 4:25. My goal was to do it in under 4:30 and was pretty happy with it. Inevitably, a bug is now in my head to try to complete it in less than 4 hrs. So, let’s see if 2017 offers that opportunity. I also managed to put in 720 miles in 2016 which is the most I’ve done in my entire life. For comparison, my previous highest was 153 miles in 2015 (133 in 2014). I also managed to cross off my bucket list goal of finishing a Half Marathon in 1:45 at the Big Sur Half-Marathon in Monterey Bay.

I am still working on improving my cadence and it’s proving to be really tough. Hopefully, the consistency and training will pay off in 2017.


All I can say, it’s been a joyous 4 years and been through some transformations both personally and professionally — and in my view all for the better.

Personal Updates (in order of priority)
– Added my 2nd offspring
– Finished 3 half-marathons
– Transformed my wardrobe

Professional Updates (chronological)
– Became a Vim user
– Learnt a lot more about Unix & Unix tools
– Grew into a lead role
– Officially became a tech leader — and this article sums up my exact feelings on the process ( The areas I fortunately didn’t have to deal with were: Financial management/budgeting, Firing People. I am saving it below since I’ve been in that role for exactly 2 years and want to save it for posterity.
– Participated in Emerging Leadership Program
– Codepath Android course — developed a few android apps and hope to work on a few more
– Switched back to an Individual Contributor role since I really enjoying being hands-on and this seems to be the better career choice for my interest at my current place of employment

My LinkedIn profile reflects what I’ve been working on but the highlight was developing and owning the InventoryService for eBay that was initially created to store inventory at retail locations to support the “Pickup-In Store” option for eBay. This also resulted in an off-shoot product (Pick-Up/Drop-Off aka. Click & Collect) that proved to be even more successful abroad which utilizes the Location services built. The service was expanded to support Inventory Management for B2C sellers with the high performance that is required for a marketplace like eBay.

2011 Summary

2011 was a rather exciting year for me, although from my posts (or lack of it), you wouldn’t have guessed that.

I had the honor of my cousin (who is a Priest-Monk) visit me early on in the year and we made a trip to Universal Studios and NASA. Towards the end of January, I started preparing for the Gasparilla 5K run which motivated me enough to run 3 days a week for 5 weeks and I managed to finish the 5K in just under 24 minutes (when I started, I took 30 mins). I also managed to cut off 10-12 pounds. After the first couple of weeks, I calculated, I would lose way more weight and finish the 5K in 20 mins but it obviously got harder to lose weight and shave time off my runs. Runkeeper was an excellent motivator and I had the awesome FeatherSound loop which was a little short of 5K. My running reduced to once a week and became non-existent a few weeks later.

After that, my parents and my in-laws visited us around my son’s second birthday and we made a road-trip to Tennessee and had a blast white water-rafting. My mom also joined us and that was her favorite part. We visited the Coke museum in Atlanta and saw the Stone Mountain in Georgia. I forgot to visit a Trader Joe’s in Georgia though since I wanted her to taste Mochi Ice Cream for a long time and I hadn’t ever found it in Florida.

After we got back, we went on a cruise to the Bahamas with my parents and it was a very relaxing trip with a lot of eating. We all got tanned (not that we needed it) and my parents left for India soon after.

In June, my wife and son left for India to prepare for my sister-in-law’s wedding and I headed to Palo Alto and stayed with my best friend. It was a fun trip and it was like living in a college dorm with 2 other guys… err.. geeks.

I got a great job opportunity while in California and accepted it. At the time, it was a tough decision to make since we would have to leave all the friends we made, move across the country and leave a great job. Anyway, I gave my notice and headed to India for my sister-in-law’s wedding. The wedding was beautiful and very well-planned. Most people who saw pictures weren’t sure if the wedding was held in the US or in India. Kudos to my sister-in-law for the months spent planning it. I had to cut my trip short and leave after the wedding to help transition my role.

After returning, time just flew by and my wife came back as scheduled, we spent time packing and getting rid of stuff. It is crazy how much you can accumulate over the years. The good thing with a move, is that it gives you motivation to get rid of a lot of it (though not enough).

I started my job at eBay in mid-September and we stayed in San Francisco for the first month and although it was a great experience, the daily commute of ~1 hour was a killer especially since I didn’t have much time left at the end of the day to do any additional reading. After days of house-hunting, my wife finally found the semi-perfect spot for us which resulted in a 10-minute commute (against the traffic). We are so much closer to a lot of places, compared to our Florida house and despite the gas prices here being higher, our fuel expenses work out to be about the same.

We got to see the Fleet Week air show with a great view and also explored San Francisco and discovered Mama’s breakfast joint (my mouth waters when I think of it). There is so much to do in California and besides loving the weather, I also love the views of mountains in the background after having spent years seeing the flat lands in Florida (although I sort of miss the (warmer) beaches).

We also visited a couple of museums, thanks to Bank of America’s Museum Sponsorship. In December, we made a trip to Monterey Bay and the surrounding areas for our anniversary + Christmas weekend. My wife had looked forward to the US-1 drive and it was as beautiful as expected. We visited the Pfeiffer Beach, McWay falls, Big Sur, Carmel-by-the-Sea and did the 17-mile drive. Needless to say, 2011 was an expensive year.

As for my job, I love it and have some awesome and really smart co-workers and we have a lot of fun (which may or may not involve drinking). We get to use a lot of technologies which was quite overwhelming initially, but an engineer’s dream. Anyways, I better stop now… gotta get some rest before our work trip to Tahoe next weekend…

Why I love Apple products

I’ve been a Mac user since 2007 and since then I’ve become somewhat of a Apple fanboy. I was first impressed with the MacBookPro’s (MBP) sleeping indicator, the casing, the magnetic power cord and just about every little feature that I wouldn’t have considered to be important prior to the switch from PCs. Seriously, every one of my past laptops external casing has formed a crack or become creaky but the MBP’s physical condition after 3 years was better than my earlier laptop conditions after 1.5 years. Granted, progress was bound to happen and the earlier plastic Macbook’s have had casing issues. I am still surprised to see Dell has plastic-like casings and are quite bulky.

I am on my second MBP now (unibody) and in terms of TCO (Total Cost of Ownership), I think the MBP works out to be cheaper than a PC. People often crib about having to pay twice the amount for a glorified machine but considering that I only used a $1200 Win Laptop for 2 years versus a $1800 Mac laptop for 3 years — the cost of ownership works out to be about the same. In terms of satisfaction, I have been more satisfied with Macs since I could still push myself to use the MBP for another couple of months whereas I was ready to throw the Win Laptop out of the window, months before the 2 years was up. Also, the ability to run Windows (via Bootcamp or via VM) along with Mac is like getting two laptops for the price of one.

Anyway, I just got back from a vacation to India and I found my old iPod Nano (which I thought I had lost) after 2 years. Here is what amazed me – I pressed the Menu button and the damn thing turned on. Correction – it didn’t just turn on, it had about 75% battery left on it. After 2 years! Let me add to that – this iPod was stored in a cupboard in a room that is not air-conditioned. Normally, heat kills off battery life/battery power (at least that’s what I’ve read). I was blown away by the fact that this iPod maintained its battery life in the heat over such a long period. Hats off to Apple! I really dont think they had emulated this test in the factories or QA department. Along with the iPod Nano, I also found my MBP remote for my first MBP and figured this thing was surely dead. But lo and behold, it worked instantly with my new MBP. No configuration needed. I am not entirely sure if that is a good thing since I could go around opening iTunes on other MBPs if I wanted to play practical jokes.

After suffering through poor battery life and months of waiting for the Android Gingerbread update to come to Samsung Galaxy S in the U.S. (which is supposed to improve the battery life), I think I am ready to switch to an iPhone – and possibly the cheaply priced iPhone 5. I kid you not, I have probably Google’d “samsung vibrant gingerbread update” at least 4 times per week over the last few months to see when an update will be released. Hopefully, Google’s purchase of Motorola will result in better hardware and quicker firmware updates.

I would also like to give a virtual shout out to Steve Jobs who just retired for being the hard-ass that he was at Apple and giving us great products. His timing on leaving when Apple was at the very top was also brilliant. If he waited for a slump, the stock would have taken a bigger hit but as always

You may also be interested in the following links:
TED Talk: Simon Sinek – How Great Leaders Inspire Action
Mac convert’s first impressions

Testing sites prior to DNS transfer

My favorite method to test a site prior to changing the DNS (to point to the new IP address) is to edit one’s own local hosts file. The hosts file is usually located in C:\windows\system32\drivers\etc\hosts (Open with notepad) or /etc/hosts (on OSX and probably *nix). The only thing to keep in mind is to remember to change the setting back later so you dont accidentally make changes on the new server thinking it is the old server or vice versa. The hosts file will be used over the DNS server to map a domain to an IP.

Below is the format of the hosts file with the IP address first followed by the domain/subdomain. You may need to enter both the www and non-www versions depending on your site

#you can comment out entries with the pound sign localhost #this entry should be there by default and is the reason why http://localhost points to

Another pro-tip is to display a “fixed” bar at the bottom of the screen to identify that you are on the new server.
Below is a snippet of CSS to display the fixed bar at the bottom of the screen along with an IE6 (now deprecated and appreciated by developers world-wide) hack. You just need to add a div with the id “dev-footer” and put a message in there.

margin:0 auto;
z-index: 9999;
font-size: 1.2em;
padding-top: 2px;
/* IE6 */
* html #dev-footer{
top:expression((0-(footer.offsetHeight)+(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight)+(ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop))+'px');

While we are talking about the hosts file, I should also recommend the LocalGhost software for Macs if you do local development with multiple sites. It is free (and open-source), stays in your MenuBar and allows you to add local host entries if you do local development and add the virtual hosts to your Apache httpd.conf file. You can check and un-check domains to take effect (or not) while you develop. So, I normally use the for my local development and when I want to test on the live server, I can just uncheck it from the menubar. It’s probably easier if you take my word for it and try this tool than my verbal explanation.

To www or not to www – update

I had posted earlier about whether it was better to use www or not to use www as a prefix to your domain. My conclusion back then was to go without www as I have done on my website. However, I have been reading more about performance improvements for websites and recently came across this nugget from Yahoo (which has some excellent documentation with regards to optimal performance – that ties to their YSlow extension for Firefox).

Another benefit of hosting static components on a cookie-free domain is that some proxies might refuse to cache the components that are requested with cookies. On a related note, if you wonder if you should use or for your home page, consider the cookie impact. Omitting www leaves you no choice but to write cookies to *, so for performance reasons it’s best to use the www subdomain and write the cookies to that subdomain.


I have often wanted to use a static sub-domain for our client sites (to increase the number of parallel requests) but the addition of having it be a cookie-less domain seems even more appealing and as the quote above describes – it is probably better to go with a www domain to avoid having a static subdomain pass cookies – if you have a large site. If you have a smaller site, you can still safely go without “www” as is the case with my site. But if your site ever grows, it could be a problem.

The one advice I wish I got earlier in life…


This advice has been out there for a long time but I am one of those people who don’t learn except through experience. Rest assured, my son hopefully won’t repeat my mistakes and will take my word for it. I have been burned by investing in stocks and have been pretty dormant this year (and still managed to lose money). When people have asked me for advice on how to advice my reply has been to short every stock I go long on and they would have done pretty well for themselves. In some ways, I am glad I learned this lesson (relatively) early in my life.

When I first started investing, I did decently and made small profits and thought I was really good at it (look out for this and understand that you are not really good at it and you just got lucky). So, I put in more money and invested and did decently until I tried digging into options (greed) and lost significant amounts of money overnight (thanks Dendreon). After this depressing incident, I still didn’t lose faith (guess it takes quite a bit of experience for me to learn my lesson) and invested in other stocks and options and continued to lose money. Tax filing season is when I am forced to face reality and remember how much I have lost – but I still tried to see the positive side of it through tax deductions (although that is limited to $3,000 loss an year).

Over the past year, I decided “CASH is KING” and remained pretty dormant on the stock front and still managed to lose money. Over the past week, I have read some interesting articles in support of investing in index funds and I plan to do that in 2011. I am just going to go with some low expense ratio Vanguard funds and probably do 60% in equities and 40% in bonds. I will probably keep my current balance in the stock market and play with it and consider it “sunk” for all financial purposes (and satisfy the little devil on my left shoulder). Hopefully, I won’t do as badly. As the first linked article notes, just be consistent and stick with it so that you don’t miss the “10 best days” of trades as that can make all the difference. I am quite pleasantly surprised with the simplistic and useful information displayed in Sharebuilder‘s Mutual Fund screeners.

Hope this helps someone (or at least my son) someday.

P.S. I should mention that if I held every single stock I lost money in till today, I would have made some money but hindsight is always 20/20 and holding Options is not an option.


tldr; Screw yahoo, screw starbucks, screw microsoft, screw dendreon, screw chipotle and screw all the other screwy stocks  you get screwed on… just go with a low expense ration index fund to minimize your chance of getting screwed.

Privacy vs Piracy


The recent debacle over the iPhone 4G leak and Gizmodo’s attempt to capitalize was on every tech news section the past couple of weeks. As you may have read, Gizmodo’s Editor Jason Chen’s house was raided and his computer equipment was seized. While, I think Gizmodo stunts were cheap and their website should get defaced (online equivalent of a punch in the face), I agree with Michael Malone’s opinion that big companies are almost totalitarian.

Despite the phone being returned and the possibility that Jason Chen could have been protected by the Shield Law, such brute force seems excessive. At first, I brushed it off since the scum got what the scum deserved. But if such incidents happen without much criticism or backlash, I fear the day when normal citizens get arrested for breaking “Terms & Conditions” or other Software license agreements.

Consider the possibility that your 12-year old son finds a copy of a pirated software on the Internet and installs it. Somewhere in the legal fine print, it states that "... you agree that you have purchased this software legally and if pirated, we warrant the ability to track you and punish you to the fullest extent of the law." Being an impatient 12-year old, your son ignores all 5000 words of the fine print and upon the first launch, the software company gets notified along with the user’s IP address that the serial number registered is a pirated version. The software company will promptly figure out the address based on the IP and arrest you, the parent (since the child is protected because of his age and it was the parent’s responsibility to monitor the child), who had no knowledge of this install. Or your computer gets seized and the cops discover the illegal music you downloaded years back and the software company sets the dogs err.. record companies go after you.

If incidents like Jason Chen’s home raid are ignored, this future will not be far… so Internet beware.