Skip to content

Instantly share code, notes, and snippets.

View cablehead's full-sized avatar

Andy Gayton cablehead

View GitHub Profile

Based on my analysis of the codebase, here's the updated spec for adding .cat -T <topic> / .cat --topic <topic> functionality:

Code Flow Analysis

The .cat command flows through these layers:

  1. xs.nu wrapper → calls xs cat CLI with flags
  2. src/main.rs CommandCat → parses CLI args, builds ReadOptions
  3. client/commands.rs cat() → makes HTTP GET to / with query params
  4. api.rs handle_stream_cat() → parses query into ReadOptions, calls Store::read
  5. store/mod.rs Store::read() → performs backlog scan + live subscription
# Create VPC
VPC_ID=$(aws ec2 create-vpc \
--cidr-block 10.0.0.0/28 \
--tag-specifications 'ResourceType=vpc,Tags=[{Key=Project,Value=vibenv}]' \
--query 'Vpc.VpcId' \
--output text)
# Disable DNS Support and Hostnames
aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-support "{\"Value\": false}"
aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-hostnames "{\"Value\": false}"

Spec: Command API Change – Use .response Frame with Collected Pipeline

Objective

  • Change command event output: Instead of streaming each output Value as a .recv event, collect the full pipeline, then append a single frame with topic <name>.response.
  • Apply return_options: The new .response event must respect the suffix and ttl from the command's return_options.
  • Remove .complete event: No .complete frame is emitted for these commands.
@cablehead
cablehead / aws.md
Last active January 16, 2025 10:31

AWS ECS/ELB Service Reference

meta: note that Nushell requires ( .. ) around multi-line commands, and it doesn't support trailing slashes for line continuation

Service Lifecycle

Task Definition Management

# Get clean task definition template (remove AWS-managed fields)
(aws ecs describe-task-definition --task-definition your-task-definition
# $env.OPENAI_API_KEY = (.head OPENAI_API_KEY | .cas $in.hash | str trim)
# $env.GPT2099_PROVIDER = { name: openai model: "gpt-4o-2024-11-20" }
$env.CEREBRAS_API_KEY = (.head CEREBRAS_API_KEY | .cas $in.hash | str trim)
$env.GPT2099_PROVIDER = { name: "cerebras" model: "llama-3.3-70b" }
$env.GPT2099_INTERACTIVE = false
$env.BOT_TOKEN = .head discord.ws.token | .cas $in.hash
Thread 26 (Thread 0x7f0be3bfd6c0 (LWP 196896) "tokio-runtime-w"):
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x000055d5f908e2d4 in std::sys::sync::rwlock::futex::RwLock::read_contended ()
#2 0x000055d5f91ea56e in lsm_tree::tree::Tree::create_internal_range ()
#3 0x000055d5f91e9aa1 in <lsm_tree::tree::Tree as lsm_tree::abstract::AbstractTree>::range ()
#4 0x000055d5f9194137 in std::sys::backtrace::__rust_begin_short_backtrace ()
#5 0x000055d5f91d0c3b in core::ops::function::FnOnce::call_once{{vtable.shim}} ()
#6 0x000055d5fa8dbbfb in std::sys::pal::unix::thread::Thread::new::thread_start ()
#7 0x00007f0c32a7ba94 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:447
@cablehead
cablehead / session.txt
Created November 7, 2024 19:17
codebuff:: example
~/s/03B..PLM/xs $ manicode
Manicode will read and write files in "/Users/andy/s/03BKRZUEAK5U4GIA2V7GTWPLM/xs". Type "help" for a list of commands.
Welcome back Andy Gayton! What would you like to do?
xs > examine src/ main.rs, connect.rs and client.rs: I want to factor connect and client into src/client/... ie, as a module factor request and parse_request_parts into request.rs in that module (along with the tests) update src/lib.rs and src/main.rs for the new location
Manicode: Reading the following files...<files>src/main.rs, src/client.rs, src/connect.rs, src/lib.rs, src/nu/commands/mod.rs, src/nu/commands/head_command.rs, src/nu/commands/cat_command.rs, src/nu/commands/remove_command.rs, src/nu/commands/append_command.rs, src/nu/mod.rs, src/http.rs, tests/integration.rs, docs/notes.md, src/error.rs</files>
I'll help factor out the client code into a module structure. Here's the plan:
@cablehead
cablehead / 01-about.md
Last active October 27, 2024 17:31
Example session with https://manicode.ai/

@rootnegativeone referred me to https://manicode.ai/

This is the output from an initial session with it. I used it to create these two commits, including the conventional commit message. The attached session just covers adding xs head. Adding xs get was even more straight forward.

These were straightforward tasks, but still pretty impressive, particularly how natural it was to amend the existing commit to add the corresponding xs.nu change. I tried to get it to update the README example with the 2 new commands, it failed at that though.

I used 565 credits to create these 2 commits (+ the failed README updates).

@cablehead
cablehead / voo.sh
Created October 7, 2024 16:07
an experiment to wire a vim buffer up to an action on save
#!/bin/bash
# Check if a command is provided
if [ $# -eq 0 ]; then
echo "Usage: $0 -- <command>"
exit 1
fi
# Remove the -- separator
shift
@cablehead
cablehead / main.ts
Created September 27, 2024 01:35
hono.localhost
import { Hono } from "jsr:@hono/hono";
const app = new Hono();
app.get("/", async (c) => {
try {
const indexHtml = await Deno.readTextFile("./index.html");
return c.html(indexHtml);
} catch (error) {
return c.text("Error loading index.html", 500);