Skip to content

Instantly share code, notes, and snippets.

cullylarson / config.ts
Last active January 30, 2024 14:23
Example configuration file
const stages = ['production', 'staging', 'development', 'test'] as const;
type Stage = typeof stages[number];
function getStage(stages: Stage[]) {
if (!stages.length) return 'production';
for (const stage of stages) {
// if any of the provided stages is production, assume we are in production
if (stage === 'production') {
cullylarson / demo.ts
Last active July 1, 2022 17:36
Typescript Branding and Flavoring
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable no-console */
/* ************************************** */
export interface Branding<BrandT> {
_type: BrandT;
export type Brand<T, BrandT> = T & Branding<BrandT>;
cullylarson / #styled-jsx-plugin-postcss-net.js
Last active January 20, 2021 22:24
A solution to slow transforms in styled-jsx-plugin-postcss.
// Most of this is copied from:
const {spawnSync, spawn} = require('child_process')
const path = require('path')
const socketPath = path.join('/tmp', 'styled-jsx-plugin-postcss--' + + '.sock')
const nodeExecutable = process.argv[0]
const clientExcutable = path.join(__dirname, 'client.js')
const serverExcutable = path.join(__dirname, 'server.js')
cullylarson /
Last active January 9, 2020 04:25
Client-side folder structure example
+ app
  - App.js
  - Layout.js
+ components
  - FormText.js
  - FormEmail.js
  - Card.js
  - CancelButton.js
 - Pagination.js
cullylarson /
Created January 9, 2019 23:21
Site Performance Checklist

Site Performance Checklist

Do these things

  • Enable gzip
  • HTTP/2


  • Chrome Lighthouse Audit
cullylarson /
Last active November 2, 2018 19:54
Headers I should probably be using
  1. Strict-Transport-Security. Ensures that all traffic, even the first request to a non-https version of the URL, will be encrypted.
  2. Referrer-Policy. Allows you to tell the browser what to set as the referrer URL when going to an external site.
cullylarson / crontab
Created October 1, 2018 17:20
Database and file backup scripts
DB_BK_CMD = /home/user/backups/site_name/
FILE_BK_CMD = /home/user/backups/site_name/
# backup / Every day @ 3 am
0 3 * * * $DB_BK_CMD do-daily database_name
0 3 * * * $FILE_BK_CMD do-daily /home/user/public_html
# rotate weekly / Every 7 days @ 3:30am
cullylarson / Pushing to a clients git
Last active March 19, 2018 17:41
Pushing to a client's git repo

Pushing to a client's git repo

I'm a freelance programmer. Sometimes I work on projects where the client wants to occasionally see code updates in their own repo, but I don't want them to see my work schedule. If I push my dev repo, they'll see when I'm working, how many hours, etc. To solve that, I started maintaining a for-client branch that only shows weekly, squashed merges of master. Each commit is monolithic, with one commit message (it doesn't include all of the individual commit times, messages, etc. from the master branch).

Convenient k8s/Docker/gcloud Commands

Commands that are useful for doing stuff on Google Container Engine


$ gcloud config set project PROJECT_ID
$ gcloud config set compute/zone ZONE_NAME
$ gcloud container clusters list
cullylarson /
Last active March 14, 2017 11:20
Catch all emails sent on a dev box and deliver them to the 'vagrant' user's mailbox
# Many apps send email. In a dev environment, we generally don't want those emails
# to get out. However, we still want our app to think it's sending mail and we want
# to verify that emails are being sent, with the correct content and to the correct
# recipients.
# This setup solves that problem by delivering all out-bound emails to the local
# "vagrant" user's mailbox. You can then read the emails using the "mutt" command.
# Most if this is copied from: