Skip to content

Instantly share code, notes, and snippets.

@bayard
bayard / chat.ts
Last active November 16, 2023 18:43 — forked from AnsonT/chat.ts
Stream OpenAI response though NextJS API route
import { NextApiRequest, NextApiResponse } from 'next'
import { Readable } from 'node:stream'
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const { authorization } = req.headers
if (!authorization || authorization !== process.env.AUTHORIZATION_HEADER) {
return res.status(401).json({ error: 'Unauthorized' })
}
const openAIUrl = process.env.OPENAI_URL as string
@bayard
bayard / nginx.conf
Created May 6, 2023 15:20 — forked from nrollr/nginx.conf
NGINX config for SSL with Let's Encrypt certs
# UPDATED 17 February 2019
# Redirect all HTTP traffic to HTTPS
server {
listen 80;
listen [::]:80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# SSL configuration
@bayard
bayard / Hyper-V PCI-Passthroug.ps1
Created May 1, 2023 20:01 — forked from Ruffo324/Hyper-V PCI-Passthroug.ps1
Hyper-V PCIe passthrough CheatSheet
# Change to name of TARGET-VM.
$vm='CHANGE_ME'
# Change to PCI device location (💡 Location).
$Location = 'CHANGE_ME'
# Enable CPU features.
Set-VM -GuestControlledCacheTypes $true -VMName $vm
# Host-Shutdown rule must be changed for the VM.
Set-VM -Name $vm -AutomaticStopAction TurnOff