Skip to content

Instantly share code, notes, and snippets.

@o-az
o-az / settings.json
Last active January 13, 2023 18:57
Tokyo Night theme custom config
{
// font stuff
"editor.fontFamily": "JetBrains Mono",
"editor.fontSize": 14,
"editor.fontLigatures": true,
// theme stuff
"workbench.colorTheme": "Tokyo Night",
"editor.bracketPairColorization.enabled": true,
"workbench.colorCustomizations": {
@o-az
o-az / add-link-tag.ts
Last active May 26, 2022 06:45
Dynamically add <link /> tag to your HTML page
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

@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
*
@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 / 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 / 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)
#!/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:
@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