Books on game design

Some time ago Austen Allred asked Twitter for game design book recommendations. Here are the crowdsourced suggestions:

As a bonus, folks also mentioned a Standford lecture on How to design addictive games and the Game Maker’s Toolkit community (Youtube / Twitter).

Shopify custom session storage in SQL with Prisma

The easiest way how to create a Shopify app is using the CLI tool provided by Shopify. A simple shopify create command sets you up with a boilerplate-but-functional app and you’re ready to go.

One of the first things you’ll need to do is to create a persistent session storage mechanism. The boilerplate app only comes with an in-memory storage. This gist shows one way how to build it, using Prisma as the model layer. It’s pretty straightforward, but it took me a while to figure out some kinks. I hope someone else will find it useful.

The way how the Shopify Node library is handling session is still being improved – I’ll update the gist as the new version is released.

How to connect to Cloud SQL in Cloud Run using Prisma

This guide assumes that Cloud SQL is configured with a public IP (the default). There are essentially three steps you need to do when you want to connect to the Cloud SQL instance from Cloud Run using Prisma:

  1. Create an IAM service account with the Cloud SQL Client role and attach it to your Cloud Run service. When deploying from the command line, pass it viat the --service-account parameter to gcloud run deploy

  2. Make the Cloud SQL instance available to your Cloud Run service. That can be done in the web console. If you’re doing it in a deploy script, you’ll need the instance connection name. It’s typically a colon separated string like PROJECT_NAME:REGION:INSTANCE_NAME. Pass --add-cloudsql-instance INSTANCE_CONNECTION_NAME --update-env-vars INSTANCE_CONNECTION_NAME="INSTANCE_CONNECTION_NAME" to the gcloud run deploy command to make it happen.

  3. Finally, tell Prisma to use the socket made available by Cloud SQL Proxy in Cloud Run to connect to the database. To do so, add a host=/cloudsql/INSTANCE_CONNECTION_NAME URL param to the DATABASE_URL. The full URL will then look something like this:
    postgresql://username:password@localhost/db_name?host=/cloudsql/gcp_project:us-central1:db. If you’re using MySQL, you might want to use socket instead of host.