Skip to content

Instantly share code, notes, and snippets.

> Hey, what's up?
[Start thinking]
Thinking Process:
1. **Analyze the Request:**
* Input: "Hey, what's up?"
* Intent: Casual greeting, opening a conversation.
* Tone: Informal, friendly.
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "numpy>=1.26",
# "torch>=2.4",
# "transformers>=4.45",
# "accelerate>=1.12.0",
# "gguf>=0.17.1",
# ]
from __future__ import annotations
import argparse
import time
from dataclasses import dataclass
import mlx.core as mx
from mlx_lm import load
from mlx_lm.generate import BatchGenerator
from rich.console import Console
# Link Discovery Assistant
You are an assistant that finds interesting links for Sam from Hacker News, Lobste.rs, and Bluesky.
## Your Task
1. **Get Hacker News links**: Use the
hackernews --top --json
command to get top stories
2. **Get Lobste.rs links**: Use the
#!/usr/bin/env uv run --script
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "requests",
# "watchdog",
# ]
# ///
import argparse
#!/bin/bash
# Configuration
WATCH_DIR="$HOME/Library/Group Containers/group.com.apple.VoiceMemos.shared/Recordings"
ENDPOINT="http://127.0.0.1:8080" # Replace with your actual endpoint
API_KEY="your-api-key" # Optional: Add if your endpoint requires authentication
# State file to track processed files
STATE_FILE="$HOME/.voice_memos_processed"
touch "$STATE_FILE"
@samwho
samwho / peek.ts
Created August 5, 2025 15:16
Peek a stream in TypeScript
/**
* Peek at the next chunk of data in the stream without consuming it.
* @param input The input stream to read from.
* @param length The number of bytes to peek.
* @returns A promise that resolves to the peeked data.
*/
async function peek(input: Readable, length: number): Promise<Buffer> {
// Try synchronous read first
const immediateBuffer = input.read(length)
if (immediateBuffer) {
@samwho
samwho / DOM.ts
Created May 19, 2025 16:38
DOM.ts
interface ExtraOpts {
class?: string | string[];
data?: Record<string, string>;
}
type TagName = keyof HTMLElementTagNameMap;
type Tag = HTMLElementTagNameMap;
type Opts<K extends TagName> = Partial<Tag[K]> & ExtraOpts;
type Child = Node | string;
import GUI from "lil-gui";
import { div } from "./DOM";
let id = 0;
function getUniqueID(): string {
return `element-${id++}`;
}
export class BaseElement extends HTMLElement {
gui?: GUI;
@samwho
samwho / bench.py
Created August 30, 2024 16:36
int vs string index benchmark
import random
import string
import time
from typing import Tuple
import psycopg2
from psycopg2.extensions import cursor
from rich.console import Console
from rich.table import Table