Skip to content

Instantly share code, notes, and snippets.

@o-az
o-az / docker-delete-everything.sh
Created Oct 28, 2022
This will delete all containers, images, and volumes
View docker-delete-everything.sh
#!/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 Jul 13, 2022
deploy .env environment variables to vercel from CLI
View vercel-deploy-env.sh
#!/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 Jul 6, 2022
update all python pip packages in one command
View python-update-all.sh
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
@o-az
o-az / middleware.ts
Created Jun 28, 2022
next-auth.js Auth Middleware for Next.js 12.2
View middleware.ts
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
*
View hello-world.md
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 / add-link-tag.ts
Last active May 26, 2022
Dynamically add <link /> tag to your HTML page
View add-link-tag.ts
@o-az
o-az / settings.json
Last active May 23, 2022
Tokyo Night theme custom config
View settings.json
{
// 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 / object.keys_literal_types.ts
Created Mar 30, 2022
Object.keys(obj) array to string literal types
View object.keys_literal_types.ts
// don't use this. I'm not sure if this is a good solution
// keeping it as notes till I find a better solution
// assume you got this from a JSON file:
const statesWeather = {
"wisconsin": "cloudy",
"california": "rainy",
"newyork": "sunny",
"florida": "cloudy",
"texas": "rainy",
@o-az
o-az / useDetectAccountChange.ts
Created Feb 19, 2022
a react custom hook to detect account change and do things
View useDetectAccountChange.ts
import * as React from 'react';
import { providers } from 'ethers';
const logout = async () =>
axios
.get('/api/auth/logout')
.then(_ => _)
.catch(_ => console.log(_));
export const useDetectAccountChange = () => {