Josh Thompson     about     archive     turing     office hours

Book Notes: 'Why We Get Fat' by Gary Taube

I recently read Why We Get Fat, by Gary Taubes. I read it shortly after reading The Case Against Sugar. My notes and a write-up on The Case Against Sugar

As I explained in that post, I find it helpful to do a ‘deep dive’ on some of the books I want to be deeply influenced by. For a variety of reasons, I have a tolerably high degree of physical fitness. I’d like to retain this fitness for a long time. Much of the fitness equation is “don’t have extra body fat”, so to that end, I’ve been doing reading on the topic.

Given how prevalent being overweight or obese is in our society, the small investment of reading a few books that might point one towards a proper course of action has ludicrously high returns.

Notes on formatting

I will be freely interjecting my thoughts throughout the rest of this review. When I quote the author, it will be denoted like such:

These are words the author has written

Sometimes they’ll extend for several paragraphs

I may choose to italicize or make bold portions of the quotations from the books. In general, these are my decisions, not the author’s.

If there are

[words wrapped in brackets]

it’s me editorializing to load the context of the quote.

My collected notes from Why we get fat: and what to do about it

Getting fat is not a “calories-in/calories-out” problem, or “eat too much, exercise too little” problem. It’s a hormonal regulation problem.

In honor of the laws of thermodynamics that they’re replacing, we’ll call these the laws of adiposity. The First Law:

Body fat is carefully regulated, if not exquisitely so.

This is true even though some people fatten so easily that it’s virtually impossible to imagine.

What I mean by “regulated” is that our bodies, when healthy, are working diligently to maintain a set amount of fat in our fat tissue — not too much and not too little — and that this, in turn, is used to assure a steady supply of fuel to the cells.

The implication (our working assumption) is that if someone gets obese it’s because this regulation has been thrown out of whack not that it’s ceased to exist.

>> Read more

Book Notes: 'The Case Against Sugar' by Gary Taube

In the last few weeks, I read The Case Against Sugar by Gary Taubes.

I found it to be compelling (more on that in a moment) and I want to be impacted by them. I want the daily decisions that I make to be subtly influenced by this author and these books.

Related but in a different vein, Nat Ellison has his collection of book notes. Derek Sivers has his. Patrick Collison has a list of books he recommends. I’ve got my own list of recommended books, but I’ve wanted to dive a bit deeper on some of them. So, like Nat Ellison and others, I’m grab-bagging quotes (helpfully brought over from highlights on my Kindle) and some thoughts interspersed between.

I’ve not settled (yet) on a format I like, but as in most things, this is an iterative process. These notes may be useful to others (at least to help them decide if the book is worth reading) but primarily this is a helpful process to me.

After reading The Case Against Sugar, I read (and did a write-up of) Why We Get Fat: And What To Do About It

Notes on formatting

I’ve included broad quotes from the book; headings, non-quoted text, bold/italicized text, etc all my addition to help with the skimming, unless I indicate otherwise.

The Case Against Sugar

The dominant views of obesity and weight have problems

Starting this out with a strong shot across the bow, Taubes argues that the “modern” understanding about why we get fat falls into two dominant approaches, and both are catastrophically wrong.

Since the 1930s, to summarize briefly, nutritionists have embraced two ideas that ultimately shaped our judgments about what constitutes a healthy diet. These would be the pillars on which the foundation of nutritional wisdom about the impact of foods — including sugar — on obesity, diabetes, heart disease, and other chronic diseases would be based. They were both products of the state of the science of the era; they were both misconceived, and they would both do enormous damage to our understanding of the diet-disease relationship and, as a result, the public health.

The first idea was that the fat in our diets causes the chronic diseases that tend to kill us prematurely in modern Western societies.

At its simplest, this focus on dietary fat — specifically from butter, eggs, dairy, and fatty meats — emerged from a concept that is now known as a nutrition transition: As populations become more affluent and more urban, more “Westernized” in their eating habits and lifestyle, they experience an increased prevalence of these chronic diseases. Almost invariably, the dietary changes include more fat consumed (and more meat) and fewer carbohydrates…

The second pillar of modern nutritional wisdom is far more fundamental and ultimately has had far more influence on how the science has developed, and it still dominates thinking on the sugar issue. As such, it has also done far more damage. To the sugar industry, it has been the gift that keeps on giving, the ultimate defense against all arguments and evidence that sugar is uniquely toxic. This is the idea that we get obese or overweight because we take in more calories than we expend or excrete.

By this thinking, researchers and public-health authorities think of obesity as a disorder of “energy balance,” a concept that has become so ingrained in conventional thinking, so widespread, that arguments to the contrary have typically been treated as quackery, if not a willful disavowal of the laws of physics.

According to this logic of energy balance, of calories-in/calories-out, the only meaningful way in which the foods we consume have an impact on our body weight and body fat is through their energy content — calories. This is the only variable that matters. We grow fatter because we eat too much — we consume more calories than we expend — and this simple truth was, and still is, considered all that’s necessary to explain obesity and its prevalence in populations.

This thinking renders effectively irrelevant the radically different impact that different macronutrients—the protein, fat, and carbohydrate content of foods—have on metabolism and on the hormones and enzymes that regulate what our bodies do with these foods: whether they’re burned for fuel, used to rebuild tissues and organs, or stored as fat.

By this energy-balance logic, the close association between obesity, diabetes, and heart disease implies no profound revelations to be gleaned about underlying hormonal or metabolic disturbances, but rather that obesity is driven, and diabetes and heart disease are exacerbated, by some combination of gluttony and sloth.

It implies that all these diseases can be prevented, or that our likelihood of contracting them is minimized if individuals - or populations - are willing to eat in moderation and perhaps exercise more, as lean individuals are assumed to do naturally. Despite copious reasons to question this logic and, as we’ll see, an entire European school of clinical research that came to consider it nonsensical, medical and nutrition authorities have tended to treat it as gospel.

>> Read more

How to Run Your Rails App in Profiling Mode

Last time, I wrote about setting up DataDog for your Rails application. Even when “just” running the app locally, it is sending data to DataDog.

This is super exciting, because I’m getting close to being able to glean good insights from DataDog’s Application Performance Monitoring tool.

For a variety of reasons, I want to run DataDog against the app as it is running locally, on my laptop. This will scale up to monitoring all this in production, but for now, I can rapidly experiment, and since we’re not deploying anything (yet) I can freely experiment with gathering/interpreting all this data locally.

The problem with running the app locally is it’s usually running on development mode, which means Rails does lots of stuff to make local development easier, but which makes actual page load time take longer.

Nate covered how to configure your app to run it in a “production-like” environment, locally, but I got tripped up in some of the minor details involved with porting generalized instructions to our specific codebase.

So, today, I’m going to explain how to run the app locally in a way that mimics production. Some of this will be specific to our app, but I some of it could be useful to anyone else with a Rails app

Required changes to config/development.rb

Nate suggested setting these options in development.rb:

# config/environments/development.rb
config.cache_classes = true
config.eager_load = true
config.serve_static_files = true # 4.2 or less
# config.public_file_server.enabled = true # 5.0 or more
config.assets.compile = false
config.assets.digest = true
config.active_record.migration_error = false
>> Read more

Setting up Application Performance Monitoring in DataDog in your Rails App

When I write guides to things, I write them first and foremost for myself, and I tend to work through things in excruciating detail. You might find this to be a little too in-depth, or you might appreciate the detail. Either way, if you want a step-by-step guide, this should do it.

As mentioned in Load Testing your app with Siege, I want to get Application Performance Monitoring in place for our app. We use Rails.

To someone who doesn’t know much about this space, there was more friction than I expected.

I’ll wander around, get everything set up, and outline any places that I bump into stuff.

First, DataDog has a handy video about how to configure your app to use APM:

Unfortunately, the link they give in the video to redirects to, which fails to tell you how to find the actual docs. 🙄

So, I found, which don’t look anything like what’s in the video. Docs go out of date, this isn’t a problem.

It looks like the setup involves a few steps:

  1. Enable Trace collection in the Datadog Agent
  2. Instrument your application to send traces to your Datadog Agent
  3. Enable Trace Search & Analytics
  4. Enrich tracing

I don’t know that we’ll get to step 4, but 1-3 look great.

Enable Trace collection in the Datadog Agent

There’s a lot of complexity boiled into this short little paragraph:

Install and configure the latest Datadog Agent. (On macOS, install and run the Trace Agent in addition to the Datadog Agent. See the macOS Trace Agent documentation for more information). APM is enabled by default in Agent 6, however there are additional configurations to be set in a containerized environment including setting apm_non_local_traffic: true. To get an overview of all the possible settings for APM including setting up APM in containerized environments such as Docker or Kubernetes, get started Sending traces to Datadog.

>> Read more

Load Testing your app with Siege

Last time, I dug into using Apache Benchmark to do performance testing on a page that requires authentication to access.

Today, we’ll figure out how to use siege to visit many unique URLs on our page, and to get benchmarks on that process. I’ll next figure out performance profiling in Datadog, and with these three tools put together, we should be ready to make some meaningful improvements to our application.

This series of posts is a direct result of Nate Berkopec’s The Complete Guide to Rails Performance, with aid from his screencasts, as well as Steve Grossi’s Load Testing Rails Apps with Apache Bench, Siege, and JMeter. Armed with these resources, and standing on shoulders of giants, off we go.

Siege’s description:

Siege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the internet. Siege supports basic authentication, cookies, HTTP, HTTPS and FTP protocols. It lets its user hit a server with a configurable number of simulated clients. Those clients place the server “under siege.”

You can get siege with brew install siege.

I’m using it because it can run a list of URLs you give it. Imagine your app is a store, and it lists a few thousand products. Each product should have a unique URL, something like, or maybe That product-guid makes sure that you can have unique URLs, even if there are two items with the same product name.

Knowing what’s in your database, you can easily concat product-guid and product-name, stick it to the end of, and come up with a list of a hundred or a thousand or ten thousand unique product URLs in your application. If you saved these to a text file and had Siege visit every single one of those pages as quickly as possible… this might look like some sort of good stress test, huh?

Dumping unique URLs into a text file

You’ll probably start working in a rails console session, to figure out how to access the URL scheme just right.

I fired up the console, and entered:"all_campaign_urls.txt", "w") do |file|
  # this opens the file in write mode; will over-write contents of file if it exists
  Campaign.where(account_id: 4887).find_each do |campaign|
    puts "writing " + "http://localhost:3000/account/campaigns/" + campaign.to_param
    file.puts "http://localhost:3000/account/campaigns/" + campaign.to_param
>> Read more