Skip to content

Instantly share code, notes, and snippets.

View chand1012's full-sized avatar

Chandler chand1012

View GitHub Profile
@chand1012
chand1012 / checkout.ts
Created April 26, 2025 15:59
Example stripe checkout code for Supabase.
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import Stripe from "npm:stripe";
import { createClient } from "jsr:@supabase/supabase-js@2";
import headers from "../_shared/headers.ts";
import type { Database } from "../_shared/database.types.ts";
type CheckoutRequest = {
price?: string;
};
@chand1012
chand1012 / obs-timestamper.lua
Last active February 28, 2025 05:41
Mark timestamps to a CSV file with OBS on a hotkey. Use the Python file to process that CSV and recording into clips. https://chand1012.mit-license.org
-- OBS Timestamp Marker Script
-- Allows marking timestamps during recording and saves them to a CSV file
-- Set a hotkey to mark moments in your recording that you can review later
obs = obslua
local marks = {}
local recording_start_time = 0
local settings_hotkey = ""
local settings_directory = ""
@chand1012
chand1012 / Notion_Page_To_Markdown.json
Created February 22, 2025 02:40
Notion Workflow to Convert a page content to Markdown.
{
"name": "Get Notion Page as Markdown",
"nodes": [
{
"parameters": {
"workflowInputs": {
"values": [
{
"name": "id"
}
@chand1012
chand1012 / notion_blocks_to_md.js
Created February 22, 2025 02:35
Notion Block output from N8N Notion Node to Markdown.
/* Helper function to extract plain text from a rich_text array */
function parseRichText(richTextArray) {
if (!richTextArray || !Array.isArray(richTextArray)) return "";
return richTextArray.map(rt => rt.plain_text).join("");
}
/* Recursively convert a list of notion blocks into a Markdown string */
function convertNotionBlocksToMarkdown(blocks, indentLevel = 0) {
const indent = " ".repeat(indentLevel); // two spaces per indent level
let md = "";
@chand1012
chand1012 / start.sh
Created January 31, 2025 17:06
Starts an avalanchego node inside docker
# Name of the Docker container
CONTAINER_NAME="avalanche-node"
# Directory for persistent data
DATA_DIR="$(pwd)/avalanche"
# AvalancheGo Docker image
IMAGE="avaplatform/avalanchego:latest"
# Mainnet network ID
@chand1012
chand1012 / random_n8n.js
Created March 26, 2024 18:50
Get a random item from an input N8N array. MIT https://chand1012.mit-license.org
function getRandomElement(arr) {
if (!Array.isArray(arr) || arr.length === 0) {
throw new Error('The input must be a non-empty array.');
}
const randomIndex = Math.floor(Math.random() * arr.length);
return arr[randomIndex];
}
const items = $input.all();
from typing import Any, List, Mapping, Optional
# pip install httpx langchain
import httpx
from langchain.callbacks.manager import CallbackManagerForLLMRun
from langchain_core.language_models.llms import LLM
class LlamaCppServer(LLM):
'''Use Llama.cpp's builtin server to remotely host an LLM for use with Langchain'''
@chand1012
chand1012 / modal_sdxl_api.py
Last active November 3, 2023 20:51
Basically ripped right out of their docs with a few modifications. https://modal.com/docs/examples/stable_diffusion_xl
from pathlib import Path
from modal import Image, Mount, Stub, asgi_app, gpu, method
from pydantic import BaseModel
def download_models():
from huggingface_hub import snapshot_download
ignore = ["*.bin", "*.onnx_data", "*/diffusion_pytorch_model.safetensors"]
@chand1012
chand1012 / big_squash.sh
Created May 4, 2023 17:53
This script squashes a git repo into a single commit with a specified commit message. MIT License https://chand1012.mit-license.org
#!/bin/bash
# This script squashes a git repo into a single commit with a specified commit message
# Check if git is installed
if ! git --version 1>/dev/null 2>&1; then
echo "Error: git is not installed. Please install git and try again."
exit 1
fi
@chand1012
chand1012 / fetchWithTimeout.ts
Last active September 20, 2024 13:52
Deno fetch with optional timeout parameter. If the request takes longer than 10 seconds (or whatever you set it to), throws an error.
// LICENSE: https://chand1012.mit-license.org
const fetchWithTimeout = (url: string, options: RequestInit, timeout: number = 10000): Promise<any> => {
return new Promise(async (resolve, reject) => {
const controller = new AbortController();
const signal = controller.signal;
const timer = setTimeout(() => {
controller.abort();
reject(new Error("Request timed out"));
}, timeout);