Skip to content

Instantly share code, notes, and snippets.

@chand1012
chand1012 / extract-frames.sh
Created October 21, 2025 16:42
Use FFMPEG for some tasks from a docker container. Mostly so I could do some media file operations directly from UnRAID.
# extract-frames.sh
#!/usr/bin/env bash
# Purpose: Extract a frame every 2 seconds from a video using Dockerized ffmpeg,
# saving frames to a directory named <basename>_frames in the host CWD.
set -euo pipefail
IMAGE="${FFMPEG_IMAGE:-jrottenberg/ffmpeg:latest}"
if [[ $# -ne 1 ]]; then
@chand1012
chand1012 / docker-compose.unraid.yml
Created October 20, 2025 06:26
Coolify Production Docker Compose modified for Unraid
services:
coolify:
image: "${REGISTRY_URL:-ghcr.io}/coollabsio/coolify:${LATEST_IMAGE:-latest}"
volumes:
- type: bind
source: /mnt/user/appdata/coolify/source/.env
target: /var/www/html/.env
read_only: true
- /mnt/user/appdata/coolify/ssh:/var/www/html/storage/app/ssh
- /mnt/user/appdata/coolify/applications:/var/www/html/storage/app/applications
@chand1012
chand1012 / polymarket_gamma.ts
Created October 13, 2025 18:01
Single-file typed Polymarket Gamma API
// src/clients/polymarket-gamma.ts
// Purpose: Strongly-typed wrapper around the Polymarket Gamma REST API using fetch. Includes response interfaces and pagination helpers.
// ChatGPT Thread: https://chatgpt.com/share/68ed3e92-bb08-8002-bd03-c86e1f8fba96
export type FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
type Primitive = string | number | boolean;
type ParamValue = Primitive | Primitive[];
type Params = Record<string, ParamValue | undefined>;
function toQuery(params?: Params): string {
if (!params) return "";
@chand1012
chand1012 / dudeify.py
Last active June 30, 2025 16:10
Magentic and PEP 723 example. https://chand1012.mit-license.org
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "fire",
# "magentic"
# ]
# ///
import fire
@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();