Payton.Codes

Musings on life, games, and code

Payton’s Blog

  • Temple of the Ruby Sands

    Temple of the Ruby Sands

    A year ago I published a Dungeons & Dragons adventure titled The Stonecutter Samurai which was written to share with my friends and co-workers at Automattic. This year I wrote another adventure, Temple of the Ruby Sands!  As it has now been played a total of seven times and I’ve cleaned up the stats and…

  • Higher Order Components and Pie Recipes

    Higher Order Components and Pie Recipes

    Higher Order Components (“HOCs”) are the latest hotness to come out of the JavaScript idea world and land in our apps. React apps, anyway. I really want to write: Higher Order Components are just wrappers, but that would be simplifying the concept too much. Wouldn’t it? Maybe. Anyway, they’re wrappers. Keep your actual Component simple…

  • Power and Love

    Power and Love

    Here’s a quote by Martin Luther King Jr. that I learned today and I really feel compelled to share: Power without love is reckless and abusive, and love without power is sentimental and anemic. Power at its best is love implementing the demands of justice, and justice at its best is power correcting everything that…

  • Test spies in PHP

    Test spies in PHP

    I think that I wrote my first unit tests in Ruby with RSpec, back in the day. But I learned most of my testing knowledge from working with mocha and chai in JavaScript. One of the things that I learned from these tools is that being able to express your test logic in clear, nearly-natural…

  • An iframe without a url

    An iframe without a url

    Sometimes you need to display html inside an iframe, but it’s not at a URL. Perhaps you got the markup from an API endpoint or generated it yourself. Maybe the markup is from a different domain and you need to be able to manipulate its DOM without cross-origin errors. For all these reasons, I created…

  • Declarative vs. Imperative Soup

    Declarative vs. Imperative Soup

    I remember not too long ago (I think this was about the time that React first came out) I was trying to understand what people meant when they said that it was “declarative” vs. “imperative”. Looking up the terms at the time didn’t enlighten me much. Mostly articles seemed to focus on the difference between…

  • JavaScript: Mocking Window

    JavaScript: Mocking Window

    When I code in JavaScript I try to avoid using the window or document objects as much as possible, but sometimes there’s just no getting around them. Bootstrapping data from a server (eg: WordPress’s wp_localize_script), manipulating the DOM directly (eg: jQuery), or listening to viewport resize events all require touching the global window object. Why…

  • Copying files… sometimes

    Copying files… sometimes

    File this one under “tools that probably only I will find useful”. In the course of my normal job I need to copy files to a synchronized directory on my computer (something like a DropBox folder). The files are JavaScript code that’s been transpiled and copying them to the synchronized directory is what deploys them…

  • Partial application and making tea

    Partial application and making tea

    Partial application is like making tea. The person making the tea needs two pieces of information: what kind of tea, and how many people to serve. We can save time by knowing one of those pieces of information before we begin. Let’s say we have a tea shop. Whenever a new person comes in with…