Skip to content

Instantly share code, notes, and snippets.

View flybayer's full-sized avatar
🤓
CEO Flightcontrol + Pilot

Brandon Bayer flybayer

🤓
CEO Flightcontrol + Pilot
View GitHub Profile
name: PlanetScale Migration
on:
pull_request:
types: [opened, synchronize]
paths:
- packages/shared/adapters/prisma/schema.prisma
env:
PLANETSCALE_ORG: flightcontrol
PLANETSCALE_DB: fc-production

Speaker Rider

by Brandon Bayer

Last updated 21 February 2023

What is a speaker rider?

As someone with immense privilege, I have a speaker rider to set expectations and boundaries around my engagement in an effort to ensure those with less privilege can also benefit from speaking at and attending events. My goal is to make the landscape more accessible and beneficial to tech's most historically excluded and marginalised communities.

Considerations

import { AuthClientPlugin } from "@blitzjs/auth"
import { setupBlitzClient } from "@blitzjs/next"
import { BlitzRpcPlugin, getQueryClient } from "@blitzjs/rpc"
export const { withBlitz } = setupBlitzClient({
plugins: [
AuthClientPlugin({
cookiePrefix: "web-cookie-prefix",
}),
BlitzRpcPlugin({
# frozen_string_literal: true
# *** Add our gems in the # YOUR GEMS near the bottom of this file ***
# DEFAULT RAILS GEMS
# This section is something close to the default Rails 5.2.3 Gemfile.
# Bullet Train updates the Ruby version. The comments in this section
# are from vanilla Rails.
source 'https://rubygems.org'
import { Controller, Get, Req, Res } from '@nestjs/common';
import { Request, Response } from 'express';
import { passportAuth } from "@blitzjs/auth"
const passportHandler = passportAuth({
successRedirectUrl: "/",
errorRedirectUrl: "/",
strategies: [
{
strategy: new PassportStrategy(), // Provide initialized passport strategy here
import crypto from "crypto"
import {assert} from "../utils"
export interface EncryptedString {
data: string
iv: string
}
export class Crypto {
static decrypt(text: string): string {
@flybayer
flybayer / blitz-image-upload-rfc.md
Last active March 16, 2021 16:59 — forked from cstrnt/blitz-image-upload-rfc.md
[RFC] Add easy image uploads to Blitz

Problem

As of right now it's not trivial to upload images in Blitz. People either use external services like Cloudinary to handle this stuff. Creating your own solution includes knowledge in the fields of form parsing and some really low level libraries like busboy.

Solution

The goal is to create a hook which allows easy image uploads. There will also be a api route which takes care of the parsing part and then allows saving the file to the disk or uploading it a S3 etc. I'm the creator of imghop and I plan on using the same / similar api for this functionality. Example:

@flybayer
flybayer / 1-BEFORE.ts
Last active January 27, 2021 23:37
Production Blitz.js Code Before & After New Pipe Utilities
// app/test-results/queries/getTestResult.ts
import { Ctx, NotFoundError } from "blitz"
import db, { Prisma, TestResult as TestResultBase } from "db"
import { ReportData } from "../types"
type GetTestResultInput = {
id: number
}
type TestResult = TestResultBase & {
import { SessionContext } from "blitz"
import db from "db"
import { authenticateUser, hashPassword } from "app/auth/auth-utils"
import * as z from "zod"
// --------------------------------------------
// PROTECT UTIL
type Ctx = { session: SessionContext }
type ProtectArgs<T> = { schema: T; authorize?: boolean }
@flybayer
flybayer / env.ts
Created September 15, 2020 23:10
zod env validation
// config/env.ts
import assert from "utils/assert"
import * as z from "zod"
assert(typeof window === "undefined",
"The config/env.ts file cannot be used in the browser")
const isProduction = process.env.NODE_ENV === "production"
const isDevelopment = process.env.NODE_ENV === "development"
const isTest = process.env.NODE_ENV === "test"