Skip to content

Instantly share code, notes, and snippets.

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "WebContainer project configuration",
"description": "https://developer.stackblitz.com/docs/platform/project-config/",
"type": "object",
"additionalProperties": false,
"properties": {
"installDependencies": {
"title": "Install npm dependencies when opening the project.",
"description": "Defaults to true. Set to false to disable.",
FROM node:lts-alpine AS builder
ARG PNPM_HOME="/root/.local/share/pnpm"
ARG PATH="${PATH}:${PNPM_HOME}"
WORKDIR /app
COPY . .
RUN npx --yes pnpm add --global pnpm@latest && \
@o-az
o-az / suppress-node-warnings.md
Last active February 17, 2023 01:28
Suppress Node.js warnings in CLI
// suppress-node-warnings.cjs

// inspired by 
// https://github.com/nodejs/node/issues/30810#issuecomment-1383184769
const { emit: originalEmit } = process;

function suppresser(event, error) {
  return event === 'warning' && error.name === 'ExperimentalWarning'
 ? false
#!/usr/bin/env ts-node
import fs from "node:fs/promises";
import tinify from "tinify";
/**
* This script will travel through the public folder and its subdirectories and
* compress all images with tinify. It will also convert all images to webp.
* then it will delete the original images.
*
* You can run this with ts-node:

Generate gpg key and add it to your GitHub account for commit signing & verification

Step 1 (Skip this if you already have GitHub CLI and GnuPG installed)

Install GnuPG and GitHub official CLI tool. Instructions:

@o-az
o-az / docker-delete-everything.sh
Created October 28, 2022 03:45
This will delete all containers, images, and volumes
#!/bin/sh
# Run with: bash docker-delete-everything.sh
# Stop all containers
docker stop $(docker ps --all --quiet)
# Delete all containers
docker rm $(docker ps --all --quiet)
@o-az
o-az / vercel-deploy-env.sh
Last active July 13, 2022 20:29
deploy .env environment variables to vercel from CLI
#!/bin/sh -
# USAGE: sh vercel-deploy-env.sh <filename> <environment>
# EXAMPLE: sh vercel-deploy-env.sh .env production
while IFS== read -r name value
do
echo "$value" | vercel env add "$name" "$2"
done < "$1"
@o-az
o-az / python-update-all.sh
Created July 6, 2022 00:04
update all python pip packages in one command
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@o-az
o-az / middleware.ts
Created June 28, 2022 20:25
next-auth.js Auth Middleware for Next.js 12.2
import { NextResponse, type NextRequest } from "next/server";
import { getToken } from "next-auth/jwt";
export const config = { matcher: "/", runtime: "experimental-edge" };
/**
* This middleware ensures auth on all routes.
* The file should be placed in the root directory of the project.
* E.g., /middleware.ts, or /src/middleware.ts
*
title publishedOn description
Hello World
2022-05-15
T3st1ng G1thub G15t5 as CeeDee En

Quick Maths:

$$ L = \frac{1}{2} \rho v^2 S C_L