Skip to content

Instantly share code, notes, and snippets.

@calvinf
calvinf / github-docker-build-and-push.yml
Created January 8, 2022 17:57
Github Action for Docker Build and Push to Google Artifact Registry
name: CI
on:
push:
branches:
- main
pull_request:
env:
# Github Container registry
@calvinf
calvinf / useNavigationLock.ts
Created December 27, 2022 21:28
Next.js Page Navigation Lock
import { useEffect } from 'react';
import { useRouter } from 'next/router';
// helpful issues/posts when building this
// https://github.com/vercel/next.js/issues/2694#issuecomment-732990201
// https://github.com/vercel/next.js/issues/2476#issuecomment-850030407
// https://github.com/vercel/next.js/discussions/32231#discussioncomment-1766752
// https://github.com/vercel/next.js/issues/2476#issuecomment-843311387
/**
@calvinf
calvinf / bun-completion.sh
Last active January 31, 2025 01:48
Bun autocomplete for bash
#!/usr/bin/env bash
_bun_complete() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Define the main commands
local commands="add build create exec init install link outdated patch pm publish remove repl run test unlink update upgrade x"
@calvinf
calvinf / Dockerfile
Last active February 15, 2025 20:37
Bun + Node.js Dockerfile
# Dockerfile for Bun (package manager) and Node.js (for runtime Next.js)
# this image includes Bun 1.x, Node.js 22, on Alpine, with Git
FROM imbios/bun-node:1-22-alpine-git AS base
RUN apk update && apk upgrade && apk add --no-cache dumb-init
RUN addgroup --system --gid 1002 nodejs
RUN adduser --system --uid 1002 nextjs
# Install dependencies only when needed
FROM base AS builder
WORKDIR /app