Josh Thompson     about     archive     turing     office hours

How to take payments via Stripe on a Static Site

I’ve had rolling around my head an idea of selling small how-to guides and resources. Things that I wish existed, but have never been able to find.

For example, I’ve read a bunch of books that talk about good Object-Oriented design, or refactoring code, or writing better tests. Despite all these books, the most useful part of learning, doing the thing you’re trying to learn, is still hard to come by.

I’m afraid that when I read a book about software, I retain only a fraction of the material, because I get so little exposure to actually writing code that exemplifies a given topic.

I went to the Turing School of Software and Designe, and they’ve got a great set of exercises for learning basic Ruby. It’s a repository of tests, and you run the tests and make them pass.

It’s one of the most effective methods I’ve encountered for learning Ruby.

I’d love for something similar to exist for learning more complex topics; targeted at early-career software developers. Shorter and more focused than a book, but more interactive and of higher quality than the smattering of blog posts one might find on the topic.

Since this is a problem I’m willing to throw money at (and have spent non-trivial sums of money on, across books, courses, and hours spent working through this material), I imagine others are willing to do the same.

Therefore, I want to simultaneously:

  1. Scratch my own itch
  2. Make these resources available for others to benefit from
  3. (Aspirationally) inspire someone else to build a course or guide to some topic I want to learn, so I can buy it.

Josh, why would you sell something like this, instead of giving it away for free?

Great question. I’ve got a few reasons:

1. I want to learn how to collect payment for something

For better or worse, much of the world revolves around exchanging money for services.

If the thing I can help you do is valuable to you, you will pay me a fraction of the perceived value to obtain said service.

I always teach what I know. There’s a running joke among some of my friends and co-workers: “Josh has written a gist about everything”.

I keep copious notes and document nearly everything I do. I love to teach others and help them, so “selling a product about how to sell a product” fits right in line with teach everything I know, despite how much it smells like a multi-level marketing scheme.

2. Putting a price on something means I’ll put a lot of effort into making it good

The difference between

Write a blog post and publish to the world


Build a first-class, best-in-breed guide to an important skill that helps people put a roof over their head

is enormous.

Putting a price on something I’ve made moves it from the former category to the latter, and I treat it with the care it deserves.

3. When someone does something for free, they are telegraphing to the recipient that it’s not worth any money

We, as humans, ascribe value to that which has evidence of value. If have two things, and one was free and the other cost money, I’m going to value the thing that cost the money more.

The thing that I’m building will deliver value. Value that is far greater than what it will cost. If I made it free, you would not value it as much.

I’ve put together a lot of resources for students getting ready to start Turing. Someone going to Turing is spending $20,000 and taking nearly a year off from earning any money to learn the skills of writing software.

They’ve got a lot invested in the program.

I put this guide in front of every new student going through the back-end program. I drop it in their cohort Slack channel before Turing starts.

You know how much interest it generates? Invariably, very little. The actual value of the material is enormous, but almost no one ascribes significant value to it.

I’ve considered putting a price on it, just so it doesn’t get lumped in with all the other free stuff out there… but I have not, and likely never will.

I’ll be honest. It’s scary to put something out there and ask people to give you money for it.

In general, when something scares you, it’s probable that pursuing that scary thing will be really good for you.

It is on this principle that I’m offering anything for sale.

Courses for sale

Change your MAC address with a shell script

For a while, I’ve had notes from Change or Spoof a MAC Address in Windows or OS X saved, so if I am using a wifi connection that limites me to thirty minutes or an hour or whatever, I can “spoof” a new MAC address, and when I re-connect to the wifi, the access point things I’m on a new, unique device.

For the record - when I’m posted up at a coffee shop for an extended period of time, I make sure to buy products regularly in payment for my time. So, if you’re spoofing your MAC address to use wifi for a longer period of time, maybe make sure to spend $5 or $10 when you run the script.

Now, in case you think that I’m actually saving myself time here, I’m totally not. Here’s why:

XKCD Automation

XKCD: Automation


XKCD Is it worth the time?

XKCD: Is it worth the time?

Here’s the steps, for someone who’s on a MAC, to spoof your MAC address:

Get your current MAC address

Hold down option key, click your wifi icon:

wifi details

Figure out which adapter your machine is using to connect to the wifi

ifconfig en0 | grep ether # one of these will return a MAC address that matches
ifconfig en1 | grep ether # the value you saw when looking for your current
ifconfig en2 | grep ether # mac address.
ifconfig en3 | grep ether # Keep incrementing the `en0` value until you run out of 
                          # devices

Here’s me working through the list:

checking all ports

For me, the very first result matched the MAC address I got from option+clicking the wifi network.

That means I’ll be using en0 as the [E]ther[N]et adapter I’ll update shortly.

>> Read more

POODR Notes: Acquiring Behavior Through Inheritance (Chapter 6)

I’m reading through Practical Object Oriented Design in Ruby .

These are some notes from chapter 6, Acquiring Behavior Through Inheritance; mostly these are for me, and they don’t intend to stand on their own. Read the book, work through chapter six, and then come back and read through this.

The current state of the code is we have this RoadBike object and MountainBike object that share significant code.

We’re going to extract common functionality into the Bycycle superclass.

Step one, according to Sandi Metz, is always move code from the base class to super class, never start with code in the super class.

class Bicycle
  # Please note how empty this class is.

class MountainBike < Bicycle
  attr_reader :size, :front_shock, :rear_shock
  def initialize(args)
    @size         = args[:size]
    @front_shock  = args[:front_shock]
    @rear_shock   = args[:rear_shock]
  def spares
    { chain:      '10-speed',
      tire_size:  '2.1',
      rear_shock: rear_shock

class RoadBike < Bicycle
  attr_reader :size, :tape_color
  def initialize(args)
    @size       = args[:size]
    @tape_color = args[:tape_color]
  def spares
    { chain:      '10-speed',
      tire_size:  '23',
      tape_color: tape_color }

mtb =
  size:        'small',
  front_shock: 'manitou',
  rear_shock: 'fox'
road =
  size:       'large',
  tape_color: "Red",

We have three broad goals:

  1. Clean up the initialization methods, so the sub-classes have sensible defaults
  2. Clean up the spares method, so sub-classes have sensible defaults
  3. Accomplish 1 and 2 in such a way that the next developer who adds a sub-class doesn’t have to inspect the existing classes in great detail to figure out subtle nuance.
>> Read more

Aggregate and deduplicate your deprecation warnings in Rails

We know we all stay on the cutting edge of Rails; no one, and I mean no one out there is making a 4.2 -> 5.2 upgrade because Rails 4.2 is no longer supported.

You, dear reader, have just suddenly found an interest in resolving deprecation warnings, and as one jumps a few Rails versions in short order, finding and resolving them systematically will save you a lot of time.

Sure, you could run tail -f log/test.log | grep "DEPRECATION WARNING", but that’s not systematic. If the same line of code gets called 50 times, and prints a deprecation warning each time, that generates a lot of noise, not much signal.

This does no one any good:

endless repeat warnings

>> Read more

Notes from 'Why We Sleep'

I first read Why We Sleep: Unlocking the Power of Sleep and Dreams about two years ago. It immediately led me to prioritize sleep over almost everything else.

Most of us don’t get enough sleep, and are worse for it. Usually when the topic of sleep comes up, I say

Hey, there’s this great book I read on sleep. You should read it, and then sleep more…

The people most in need of more sleep are also usually the people most unable to make time to read a book about sleep. So, here’s an effort to help these people save time, prioritize sleep, and then maybe give the book a read anyway.

I hope to use this post to accomplish two things:

  1. Convince you that sleep is massively important and you should sleep more
  2. Convince you to read the book. If you find anything below compelling, you’ll find it even more compelling if you read the whole book yourself.

Everything that follows is a quote from Why We Sleep.

If I add my own comments, they’ll be inline and italicized, like so:

Josh: here’s a comment I’m adding

Please note: Alexey Guzey did a fantastic review of the science in the first chapter of this book: Matthew Walker’s “Why We Sleep” Is Riddled with Scientific and Factual Errors. As you might guess from the title of the piece, there are some big problems with the science Matthew Walker users to justify his arguments.


I’ve quoted from this book, extensively. I don’t recommend reading this post top-to-bottom, but rather jumping around the post, from this following index, to a section that looks interesting, then going back to the top, jumping to a different section, etc.

Quotes from Why We Sleep:

Two-thirds of adults throughout all developed nations fail to obtain the recommended eight hours of nightly sleep.

This is the grab-bag of negative impacts on sleeping too little. From the first chapter. The author expands on all of these points later in the book.

  • Routinely sleeping less than six or seven hours a night demolishes your immune system, more than doubling your risk of cancer.
  • Insufficient sleep is a key lifestyle factor determining whether or not you will develop Alzheimer’s disease.
  • Inadequate sleep — even moderate reductions for just one week — disrupts blood sugar levels so profoundly that you would be classified as pre-diabetic.
  • Short sleeping increases the likelihood of your coronary arteries becoming blocked and brittle, setting you on a path toward cardiovascular disease, stroke, and congestive heart failure.
  • Fitting Charlotte Brontë’s prophetic wisdom that “a ruffled mind makes a restless pillow,” sleep disruption further contributes to all major psychiatric conditions, including depression, anxiety, and suicidality.
  • Perhaps you have also noticed a desire to eat more when you’re tired? This is no coincidence. Too little sleep swells concentrations of a hormone that makes you feel hungry while suppressing a companion hormone that otherwise signals food satisfaction. Despite being full, you still want to eat more. It’s a proven recipe for weight gain in sleep-deficient adults and children alike.
  • Worse, should you attempt to diet but don’t get enough sleep while doing so, it is futile, since most of the weight you lose will come from lean body mass, not fat.

Add the above health consequences up, and a proven link becomes easier to accept: the shorter your sleep, the shorter your life span.

The old maxim “I’ll sleep when I’m dead” is therefore unfortunate. Adopt this mind-set, and you will be dead sooner and the quality of that (shorter) life will be worse.

>> Read more