• 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.


  • Dieting, productivity, and the Whole30

    Dieting, productivity, and the Whole30

    Many of you know I’ve been following the Specific Carbohydrate Diet for the past 3 months due to some mild GI problems I’ve suffered from since late 2011. Among other things, the SCD controls the types and quantities of certain difficult-to-digest carbohydrates that are common in the modern food supply.

    SCD has been, in a word, amazing. I began seeing improvement in my symptoms almost immediately. My initial goal was to spend 90 days on the diet and evaluate at that point if I wanted to continue. Well, I hit my 90 days on Friday, January 9th and am still doing SCD. Not only have my symptoms improved, but I feel so incredible that I can’t imagine going back to the SAD (Standard American Diet) at this point. I wake up every morning with plenty of energy that lasts through the entire day. I’ve lost weight without even trying. And my productivity at work has soared.

    This eating plan has been a big win. However, I’ve struggled to communicate with my friends about why I’m not eating the way they do any more. Part of this is a marketing problem. The SCD was developed by Elaine Gottschall and explained in her book, Breaking the Vicious Cycle, published in 1994. Now I enjoyed reading her book, but it does have a lot of science in it and frankly, it makes the diet seem very complex. So it’s not a book I find myself recommending very often.

    Not only does it present the SCD as being complex, it doesn’t describe just how darn amazing a person can feel by eating whole, unprocessed foods and focusing on healthy fats and proteins instead of carbohydrates. This is a shame since I didn’t realize how lousy I was feeling eating the SAD until I changed my diet.

    Enter the Whole30. I recently finished reading It Starts with Food by Dallas and Melissa Hartwig where they introduce a 30-day plan for eating whole, unprocessed foods. It’s essentially the SCD but with better marketing. Now this is a book I can recommend wholeheartedly! The authors do a great job explaining the science behind the Whole30 in an easy to understand way, and they go even further by describing the myriad benefits of eating this way. They also include plenty of practical advice about how to eat whole foods in a world where processed is the norm.

    Now sure, there are foods like pizza and doughnuts that I find myself longing for at times. But the fact is, there is so much real food that I can eat that doesn’t make me feel lousy, and it’s downright delicious. I was never much of a cook and I worried about having to become one if I changed my diet, but this hasn’t been a problem either. It’s been fun learning a new skill, and it didn’t take long to come up with some basic dishes that I enjoy fixing on a regular basis.

    Saturday has become my big cooking day. I do my shopping early in the morning, cook all my veggies for the week, and stick them in the fridge. I’m usually done by noon. Then all I have left to fix each evening is the meat. I fix a double portion which I use for dinner than night. Leftovers serve as lunch the next day. That way I’m only cooking once a day during the week (excluding breakfast but my breakfast lately has been Bulletproof Coffee which doesn’t require any cooking).

    I can say without reservation that, after experiencing what it’s like to be on a whole foods diet, I will never go back to eating the SAD again. If you’re curious and want to experience these incredible results for yourself, I encourage you to at least read through the book once. You don’t have to follow the plan if it seems silly to you. But at least read the material. I guarantee you’ll learn something you never knew before.

    Have you tried the Whole30 or a similar diet? How did it work for you? I’d enjoy hearing what your experience has been. Please feel free to leave a comment below.

  • I met with Susan Hand last week to convert my incredibly long list of goals for 2015 into an actionable plan. By the end of the hour, I had a spreadsheet categorizing my goals into 3 main areas:

    • Consulting (currently my core business)
    • Programs/Products (things that will replace my consulting income eventually)
    • Personal (basically everything else)

    Susan also had me rank each goal according to whether it would generate revenue immediately or later, and whether it was mandatory to get done this year or merely optional. It was a good exercise since it forced me to think deeply about each goal and consider what would need to be done to declare the goal “complete.”

    We also did some preliminary scheduling of goals for each quarter of the year. It’s a great start to assembling a comprehensive business plan for the year. Susan helped me transition from my “brain dump” into something organized, prioritized, and understandable.

    The next steps I’ll need to take to continue developing this plan are:

    1. Using the worksheet we started, spend some more time documenting my “ultimate” 2015 goals and activities for my core business, programs, and personal growth.
    2. Start a 12 month calendar and start blocking out holidays, vacation, travel plans and events. These are the days that I already know I’m not going to be working.
    3. Once I’ve completed the 12 month calendar it’s time to start laying in my quarterly, monthly and weekly plans. I’ll start with what goes in each quarter and then break it down by month. If I’m not sure what month I’m going to do something, I’ll leave it in the quarter list until the quarter gets closer and move it down to the month at that point.

    I want to thank Susan for sharing her time with me. If you’re looking to develop a similar business plan for 2015, get in touch with her. I’ll be posting periodic updates as I continue building out my own plan and executing on it. In fact, I may dedicate a entire post to executing on goals in a few weeks. It’s something I struggle with. I’m sure I’m not alone in this, but in my experience it’s much easier to come up with goals than it is to actually bear down and start doing the work necessary to achieve them. Procrastination springs eternal.

  • I established some general goals for 2015 in my 2014 annual review, however I’ve since become convicted about being more specific about these goals and describing them in a bit more detail. Fortunately, my friend Susan Hand is a project manager and has graciously offered to donate some of her time this week to assist me in refining and organizing my goals.

    Here’s my not-so-short list of things I want to accomplish this year. These aren’t in any particular order and they aren’t categorized very well. Realistically, many of these probably can’t be accomplished in 2015 (if at all). I’m only one person and don’t have infinite time and resources (though I wish I did). But the first step to accomplishing something is establishing it as a goal. So here we go:

    • Establish realistic quarterly goals for the year
    • Maintain my existing monthly revenue from consulting
    • Finish building my 7 Days to Kick Sugar email course
    • Finish building my How to Build a Transcript email course
    • Hire a contract writer to improve copy for Teascript, my SaaS app
    • Hire a contract writer to create a companion eBook for Teascript
    • Aquire and execute a marketing plan for Teascript
    • Double monthly revenue from Teascript by the end of the year
    • Put Teascript on “autopilot” by automating or outsourcing time consuming tasks
    • Move my blogs from AppFog to Linode
    • Write a new post on my personal blog each week
    • Write a new post on my distance education blog each week
    • Put up Facebook/Google+ pages for my company, Adeptware
    • Put up Facebook/Google+ pages for my consulting services
    • Assist with organizing a local tech conference
    • Present at the Triangle Ruby meetup
    • Present at the Agile RTP meetup
    • Attend Triangle Startup Weekend
    • Build a web site “health check” SaaS app
    • Build a SaaS app to establish, track, and achieve life goals
    • Write an eBook about how to manage variable income as a freelancer
    • Write an eBook about nutrition for developers (or more generally, freelancers)
    • Revise and re-release the Career 2.0 eBook with Jared Richardson
    • Exercise consistently 3 times per week
    • Select and hire a good financial advisor
    • Rollover my old 401(k) to an IRA
    • Pay off my home mortgage
    • Learn more about real estate investing
    • Start attending a real estate investing meetup
    • Find a real estate investor who can be a mentor
    • Aquire a piece of investment real estate
    • Learn more about investing in privately held businesses
    • Invest in a local privately held business
    • Continue on the Specific Carbohydrate Diet

    Yes, it’s a lot. I’m sure Susan will help me whittle this list down to something more manageable. It should be interesting comparing this list with whatever comes out of my meeting with her. Check back next week for those results.

    Have you established any goals for 2015 yet? Is your list as crazy as mine? Post a comment and let me know what you’re planning.

  • I’ve been pondering what my goals in 2015 should be. There are many things I want to accomplish this year. I plan on writing about them next week. But this week I want to highlight a product I began working on over Christmas break. It’s called 7 Days to Kick Sugar.

    I’ve been learning a lot about the damaging effects of sugar in my diet. Dr. Robert Lustig’s book Fat Chance has been an eye opener. Apparently, fructose (found in table sugar, fruit, and 99% of the processed food items you’ll find at the grocery store) is a metabolic poison when over-consumed. It makes the liver sick and fatty and causes metabolic syndrome (obesity, diabetes, high blood pressure, etc). It’s not hard to over-consume fructose either, especially given the overwhelming presence of High Fructose Corn Syrup in the modern American diet.

    Dr. Lustig explores the reasons behind our overconsumption of fructose (besides the fact that is tastes amazing). He also suggests some ways that we as a society can solve this massive problem. One of his recommendations is to only consume fructose in its natural form: whole fruit. Apparently, fiber is critical to “blunt” the impact of fructose on our liver which is why fruit juice is not a healthy option. And even when consumed from fruit, our fructose consumption should be limited to 15g per day or less.

    I’ve been limiting my sugar consumption for the past couple of years. I only consume whole fruit. I never consume HFCS or anything with added sugar. I’ve cut soda and fruit juice out of my diet completely. And I feel fantastic. I wake up each morning full of energy, and this energy sticks around the entire day. I used to get very tired after eating lunch, but this doesn’t happen any more. In short, cutting sugar out of my diet has increased my productivity and my enjoyment of life. And I want others to be able to experience that too.

    That’s why I started building this email course over Christmas. My first few weeks without sugar were pretty rough. It’s an addictive substance and it can be very hard to stop consuming it. I literally had withdrawal symptoms. The intention is for this course to provide a daily dose of encouragement, as well as a single actionable step you can take that day to eliminate sugar. By the end of the week, you’ll be feeling amazing.

    I’m roughly 50% finished writing the course. The pre-launch page live. I’d very much appreciate feedback on the content. Additionally, if you sign-up to be notified when the course launches, you’ll receive a free infographic listing 56 different names for sugar that often appear in ingredient lists. It’s going to be a fun ride. I hope you’ll join me.