• CORS woes on Heroku

    ,

    After spending the past 4 hours attempting to solve what boiled down to a rather simple problem, I figure I’d better blog about it to save someone else the time and effort.

    If you’ve been leveraging Passenger’s new –nginx-config-template command line option to add CORS headers to static assets served from a Rails app hosted on Heroku, and the CORS headers recently disappeared under mysterious circumstances… read on.

    I’ve been using the method described here to add CORS headers to custom fonts served from a Heroku-hosted Rails app that’s proxied by Nginx which handles serving static files. I recently updated to Rails 4.2.2 and suddenly, my custom fonts (.woff and .woff2 files) no longer had CORS headers on them.

    After the aforementioned hours spent scratching my head, I discovered that the latest version of the sprockets gem is generating asset digests that are 64 chars in length, where previously they had been 32. Nginx’s default regexp for identifying requests for static assets assumes the digest will be 32 chars long, like so:

    # Rails asset pipeline support.
    location ~ "^/assets/.+-[0-9a-f]{32}\..+" {
      error_page 490 = @static_asset;
      error_page 491 = @dynamic_request;
      recursive_error_pages on;</code>
    
      if (-f $request_filename) {
        return 490;
      }
      if (!-f $request_filename) {
        return 491;
      }
    }
    

    Changing the regexp to recognize digests that are 64 chars in length immediately solved the problem:

    location ~ "^/assets/.+-[0-9a-f]{64}\..+" {
       ...
    }
    

    I had to laugh after something so stupid and silly cost me a good chunk of my Saturday to debug. But at least it’s working now. My statically served custom fonts have the correct CORS headers and Chrome and Firefox are happy again.


Need help?

I’m an independent software developer available for consulting, contract work, or training. Contact me if you’re interested.


  • Why I’ll never buy from Virgin Mobile again

    Why I’ll never buy from Virgin Mobile again

    Today’s post is a bit self-serving and for that I apologize, but I’m hoping that telling my story publicly will accomplish 2 things: first, it will warn my readers that they do business with Virgin Mobile at their own risk. Second, and it’s a long shot, but it might provoke a response from VM and they might return the money they’ve owed me for years. A very long shot, I realize.

    “Trust, but verify.” I learned this lesson in early 2011. I have nothing against Virgin as a brand or a company. I admire Richard Branson and all he’s accomplished. He’s a remarkable example of a self-made entrepreneur. However, I can say without hyperbole that he has some real dolts working for him at Virgin Mobile.

    In December of 2010 I was looking for a mi-fi provider. I didn’t have an iPhone to tether with yet and needed an option to connect to the Internet while on the road. Virgin Mobile seemed to have the best deal at $130 plus S&H for a MiFi 2200. They also touted a 30 day money back guarantee which gave me confidence in making the purchase.

    When the device showed up, I quickly discovered that the coverage was not satisfactory for my area. I would frequently get dropped connections from home, and when out and about coverage was even spottier. So I called VM on January 5 to request service cancellation and get instructions on how to return the device for a refund. The rep I spoke with put me on hold for 20 minutes then said she would call me back later that night. She never did. Thus began 6 months of pure and utter frustration.

    • January 7: called a second time to find out what happened. Rep said they were sending me a mailing label to return the device. I waited over a week for the label to arrive but it never did.
    • January 16: called a third time to ask where the label was. The rep wanted to transfer me to the “mi-fi group” (first I had heard of this) but actually just dumped me back out to the automated call menu.
    • January 17: called a fourth time and the rep finally gave me an address and RMA for the device. I shipped the device back the same day via UPS and included a note in the package explaining in detail about what had happened.
    • January 19: UPS reports the package was delivered.

    Between January and June 2011 I called Virgin Mobile a total of 6 times to ask why my refund had not been processed. Each time I was told that it would be processed within a week. Each time the refund failed to appear.

    I switched to a different tactic and opened a service ticket through their web site. Here’s their response:

    We do understand how frustrating could be not having the answers when you need them. Unfortunately, there are procedures we have to follow and your issue is under review at this time. All we are asking you is for a little time in order for us to resolve the issue at your satisfaction. Again, we are deeply sorry for the delays, but we need to wait for the investigation that we have opened regarding the refund of your device.

    We have already confirmed your device has been returned and it might take up to 5 business days for us to have a resolution.

    So they admit they received the package. But for some reason, issuing a refund is a challenge for these people. Subsequent service tickets were equally useless. My refund was always “in process” or “under review.”

    Eventually, they claimed they had mailed me a refund check. The check never arrived. Subsequent customer service requests yielded no help whatsoever. Refusing to explain why I hadn’t received a check yet, they instead began telling me they couldn’t help me and that I had to contact the “Broadband department” for a refund. Whatever. I give up.

    By the time August 2011 rolled around I decided it was not worth the time and effort to continue pursuing this. So Virgin Mobile kept my money and I’ve heard nothing from them since. Overall, it’s a frustrating and disappointing experience when a company steals your money. Had I anticipated what was going to happen I would have kept the device and sold it myself. I wouldn’t have gotten all my money back, but I would have gotten something. As it happened, Virgin Mobile ended up with both the device and my money.

    Be warned. When it comes to Virgin Mobile, advice from The Princess Bride is appropriate: “Get used to disappointment.”

  • Pricing a SaaS app is hard

    Pricing a SaaS app is hard

    Pricing a SaaS app is hard. Really hard. My flagship product Teascript launched with a subscription-based pricing model in 2007. This was primarily due to a limitation in the payment system I was integrating with. I did a bit of “market research” before settling on $19 per year for unlimited use of the app. (And by “market research” I mean that I Googled some keywords related to my app to find competitors and learn what they were charging.)

    This pricing stuck for several years but I eventually realized the amount of value I was providing through the app did not match the price tag. As I continued building new features, the value was increasing and I needed to change my pricing accordingly. I also decided to move from an annual charge to a monthly charge, mostly because I wanted a shorter feedback loop to measure churn.

    I switched all subscriptions to $5 per month and also put a cap on app usage (which in hindsight, I should have been doing from the start but that’s a topic for another post). Surprisingly, this actually increased my sales even though the effective annual rate had more than tripled to $60. Why was this?

    I was scratching my head initially until I realized many of my users were signing up for one or two months and then canceling their subscriptions. So I had actually increased churn by moving from an annual to a monthly charge. But that told me something about how my customers were using the app. Teascript helps homeschoolers and private schools build high school transcripts for their students. This is something that’s typically only done once in a student’s lifetime. Therefore, even in a family with 3 or 4 kids, a parent is only going to be using the app for a few months at a time per student, then they won’t have any further need for it.

    This leads me to believe that moving to a fixed pricing model may be the right approach. Recently, I’ve been experimenting with various metrics to try to measure how much money I make off a typical subscriber. If most of my customers only remain subscribed for 3 or 4 months, that’s $15 to $20 of revenue. If I had instead been charging a fixed price of $39 (a price point comparable to most offline high school transcript kits) then I would have nearly doubled my revenue.

    I still haven’t found a reliable way to determine the lifetime value of a customer, though. I’ve been experimenting with various Stripe metrics providers but haven’t found anything that calculates metrics based on the past 7 years of payment data I have in Stripe (everything I’ve found only calculates metrics going forward). When I do figure this out, I’ll be sharing the results here. Stay tuned.

    In conclusion, did I mention pricing is hard? There are so many different ways to price an app. It’s hard to know ahead of time what will work for any given app. This is where A/B testing and customer feedback can be helpful. Even with that additional information, though, I feel like it’s something that could take a lifetime to master. I’m well on my way, but I still have a lot to learn.

    Have you run into challenges pricing a SaaS app? Share your story in the comments.

  • Nomadic programming (part 2)

    Nomadic programming (part 2)

    It’s time to re-visit nomadic programming. Read part 1 to get caught up.

    nomad [noh-mad]: (1) a member of a people or tribe that has no permanent abode but moves about from place to place, usually seasonally and often following a traditional route or circuit according to the state of the pasturage or food supply. (2) any wanderer; itinerant.

    As defined in part 1, a nomad is a freelancer who spends the day roaming between various wi-fi hotspots instead of working from home. This isn’t just about hanging out at a coffee shop like a hipster. This is about getting out of the house and into a more stimulating environment, creating opportunity for networking, and yes, enjoying some delicious food and drink in the process.

    So now that you’re onboard with the concept, what’s the actual procedure for being a nomad? I’ve been nomading for 8 years and have picked up a few tips and tricks that I’ve found maximize enjoyment and productivity. Follow these guidelines for nomading success.

    What to do

    • Bring a power splitter. Finding outlets is the perennial problem of the nomadic programmer. Most cafés and coffee shops have only a handful of outlets available. Instead of having to arrive early to snag one, bring a power splitter with you and politely ask to throw it on an outlet that’s already in use. If you get a big enough splitter, you can even offer power to fellow nomads who weren’t as forward-thinking as you were. This highly portable splitter is one of my favorites.
    • Bring headphones. Some people enjoy the noise at coffee shops, true. Even if you’re one of those people, it can be helpful to have a pair of headphones on you if the noise becomes too much, or if you need to watch a video or listen to a podcast. If your headphones have a boom mic, so much the better. It’s practically impossible to participate in a conference call in the midst of heavy background noise without a headset mic. I’ve used this model from Logitech for years. It’s light, inexpensive, and works well.
    • Tethering means freedom. Wi-fi hotspots are ubiquitous these days, but with that ubiquity comes increased unreliability. Slow wi-fi is the bane of the productive freelancer. That’s why you should always have a backup. Tethering to your iPhone, iPad, or Android device is the equivalent of “wi-fi insurance.” It’s a relatively inexpensive way to ensure you’ll always be able to get online, even when the hotspot at Starbucks is being rebooted. It also opens up a world of new nomading locations. I once ran a conference call with a client from beside a beautiful golf course. That wouldn’t have been possible if I hadn’t brought my own wi-fi.
    • Carry business cards. One huge benefit of nomading is the opportunity to meet and network with people. It’s amazing how frequently this happens. Don’t get caught without a stack of business cards. You need something to hand out to people you meet so they can follow up with you later. I actually landed a freelance job from someone I met at Bruegger’s once.
    • Bring a water bottle. Most cafes and coffee shops offer water, but the cups are usually tiny. Purchasing bottled water is always an option, but staff are usually happy to refill your bottle for you. I like these stainless steel bottles for their size, durability, and tactile feel.
    • A wireless mouse can’t hurt. It’s nice having an alternative to the trackpad, especially if you’ll be nomading for more than a couple of hours.
    • Use a quality bag. It’s important to have something to carry your stuff in. Don’t cheap out here. A good bag will serve you for years. I like 5.11 packs. They don’t have a fancy padded pocket for your laptop, but they’re practically indestructible.

    What not to do

    • Don’t dress like a slob. It’s easy for us programmers to let our clothing choices slide into the gutter. When we’re nomading, though, we’re out in public. We’ll be meeting new people. Some of those people might be potential clients. So it’s important that our dress reflect our professionalism. I’m not saying you need to wear a tux to Starbucks, but you should probably reserve the ratty jeans and stained T-shirt for home.
    • No freeloading. It’s incredibly inconsiderate to park yourself at an establishment, use their wi-fi, and not buy anything. Don’t do it.
    • Don’t ignore the owner and staff. Along those same lines, building good relationships with the business owner and staff can be very rewarding. When you become a regular customer, leave good tips, and clean up after yourself, the staff will remember and you’ll get better service as a result (and even some freebies at times).
    • Make healthy choices. Modern America is sedentary. As programmers, we’re likely more sedentary than the average American. That’s why it’s critical to make healthy choices while we’re out and about. Pass on the morning bagel or doughnut doughnut and enjoy some bacon and eggs instead. You don’t need that soda, unsweetened tea has far fewer calories and won’t trigger an afternoon crash. And try to get out for a brisk 20 minute walk at some point.
    • Security matters. Whenever you’re using public wi-fi you’re taking a risk. That risk can be mitigated by using a VPN or, better yet, by always tethering to your own wi-fi connection. Portable wi-fi hotspots are inexpensive and provide an extra layer of protection.
    • Avoid peak times. Nothing is worse than trying to perform an emergency deploy to a production web server during the lunch rush at Moe’s. A technique I’ve found helpful is to hit the popular lunch spots during mid-morning, hop over to a coffee shop during the lunch rush, and head back to the café during the afternoon lull. I despise overcrowded places and this technique was quite effective at ensuring that my surroundings were relatively calm throughout the day.

    Conclusion

    Pretty straightforward, right? Take what you find useful from these lists. Discard what doesn’t work for you. Come up with some best practices of your own. Half the fun of nomading is the adventure. Where will you end up? Who will you meet? You never know what each new day might bring. So get out there and start identifying your favorite places to nomad.

    If you’re not sure how to get started, consider joining a local programming Meetup like this one. Even user groups will occasionally host a social gathering at a restaurant or coffee shop. Just keep in mind that while nomading as a group can be fun, the real adventure resides in striking out on your own.

    Have you tried nomadic programming? Did you enjoy it or despise it? Do you have any tips or tricks that worked for you? Share your experience in the comments below.

  • I’ll admit it: I’ve been coveting a standing desk for years. The idea of escaping the uncomfortable prison of my 10-year-old desk chair is compelling. But standing desks are prohibitively expensive for many people, and up until recently that included me.

    My new standing deskIt finally got to be too much, though. A few weeks ago I bit the bullet and, after doing extensive research on the various options available, finally settled on the NextDesk Terra. There are many companies that manufacture standing desks, but NextDesk seems to offer the best quality-to-price ratio. I also appreciate the built-in Belkin power strip. And let’s face it, their bamboo desk surfaces are downright gorgeous.

    And the motorized raising and lowering is definitely the “wow” factor. Is it necessary? Not really. I guess the argument could be made that the motor is saving my back from having to manually crank the thing up and down, but this being my first standing desk it’s hard to say how much more difficult a manual lifting mechanism would make things. But I’m happy with the motor.

    How often do I find myself standing now that I have the correct equipment? Almost all the time. I easily spend 80% of my work day standing. What’s nice about leaving the desk in its raised position is that it’s so easy to just walk up to the workstation and get something done. My office is in my converted dining room right next to my kitchen, so I’ll often find myself wandering over to get something done while I’m waiting for some water to boil on the stove, or waiting for the microwave to finish warming a bowl of soup.

    Eliminating the need to sit before using the computer has lowered a psychological threshold that was preventing me from handling small tasks when a few minutes of free time suddenly appeared in my day. When I had to sit, I wouldn’t bother because my brain was telling me it would take longer to perform the action of sitting than it would to get something done once I did sit.

    If you’re considering upgrading to a standing desk, I recommend glancing over this article which was instrumental in my decision. Do you already use a standing desk? Comment below and let me know which model you chose and what you like best about it.