Tag: js
-

Using Tiled editor for The Lost Card
It’s still amazing to me that I managed to finish an actual game for the first time. A lot of my success with The Lost Card I owe to the Tiled editor. I wanted to write a little blog post to explain all the ways in which I was able to leverage it to make…
-

Enemy State Machines in Lost Card
This summer I made a simple game called The Lost Card using TypeScript and the Phaser framework. I wanted to write a little about some of the things I learned during that process. This post is about enemy behavior. Once I had a character I could move around my world, I needed to have enemies…
-

The Lost Card
I was first inspired to become a software developer when I was very young when I got an original NES. Playing those early games gave me a passion to learn programming that was the foundation of everything I’ve done since. Back in the early days when I was just studying BASIC and Hypercard, I made…
-

Good coding practices
I recently had to give a talk on “Good coding practices” for some new developers at Automattic. At first I had no idea how to summarize such a vast and dynamic topic, but as I was working on a plan I started to see some ideas come up over and over again and I decided…
-

Lightweight rendering of React to strings
For a recent project I needed to be able to render React components (or really, just React-like components) into plain HTML strings. Of course, React provides a mechanism to do this: renderToStaticMarkup in its ReactDOM library. But wow, that library is a really big dependency to import if I don’t want any of the DOM reconciliation…
-

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…
-

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…
-

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
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 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…