Right-joining a table that uses soft delete in Python SQLAlchemy

Typically when implementing a new SQL table, I use soft deletes over hard deletes. Soft deletes enables one to make audit operations without having a separate analytics system, and in many cases (say, purchases which reference old inventory), soft deletes are a requirement.

The only issue is when you try to join a table with soft deletes, funny things can happen. Take the following query, where we have accounts, and active credit cards for people to perform payment, which can …

Reflections on ALC/LifeCycle

It’s been on my bucket list for a few years to bike from San Francisco to Santa Cruz. It’s a beautiful ride along the California coast and takes the better part of a day. At the beginning of this month, I completed that ride, spent the night in a tent, and then kept on biking on my way to Los Angeles.

As part of AIDS/LifeCycle this year, roughly 2200 cyclists rode from San Francisco to Los Angeles …

Identifying Sources of Cost Disease

Cost disease is one of, if not the, most important problem for society to be tackling right now. Cost disease is the notion that many industries have become dramatically more expensive over time, rather than less expensive, as you might expect with technological improvement. To put cost disease in a political frame, I greatly enjoy this quote from Scott Alexander:

Libertarian-minded people keep talking about how there’s too much red tape and the economy is being throttled. And less …

Book Discussion: Checklist Manifesto

Humans are fallible. This idea is the theme of the past three books I've read. Pitch Anything focuses on the idea that people typically make decisions at an instinct level rather than analytically. The Undoing Project shows how humans are heuristic machines, and while the heuristics are right in many cases, they are systematically wrong in others. The Checklist Manifesto prescribes fixes for the limited capacity of our memory and problem-solving ability.

I'm already familiar with the effectiveness of checklists …

Book Notes: The Undoing Project

Humans are fallible. Importantly however, humans are fallible in predictable ways. That is the main argument of The Undoing Project, and the elucidation of the specific ways we are fallible makes this book one that is worth reading.

These notes are part original and part passages from the book.


The Israeli military measures the performance of their fighter pilot training programs. They discover that pilots perform better after criticism and worse after praise. What is the problem with this …

Book Notes: Pitch Anything

Pitch Anything is a highly entertaining, and based on the anecdotes from this book, highly effective, sales book.

The methods described are evocative of pick-up artist book "The Game" and might not sit well with everyone. People should learn the sales style that works most effectively for themselves.

These notes are part original and part passages from the book.

Core Idea

The core idea in the book is that everything gets filtered through the limbic system (aka "croc" brain). If …

Dark Money

Dark Money is a both a roller coaster tale and an effective playbook of political influence. It tells the story of the Koch brother’s legacy on both the dialogue of American politics and the platform of the republican party. It made me realize that significant changes to our political landscape (e.g. rise of the Tea Party, Citizens United case) were not random developments in our nation’s history, but were events engineered to occur. It made me realize …

The Golden Handcuffs Are Tighter Than You Think

New CS grads are often showered with salary, perks, and equity. When I was graduating, I had no idea how any of this worked. How does tax work? How much will my shares be worth? I joined Uber after college, a company few people doubt will IPO and do so successfully, but still there were still many surprises. I'm going to walk through how equity grants work, so that the new grads among you can make better informed decisions.

In …