Skip to content

Instantly share code, notes, and snippets.

View cablehead's full-sized avatar

Andy Gayton cablehead

View GitHub Profile
@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);
@cablehead
cablehead / main.ts
Created September 27, 2024 01:32
oak.localhost
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
const router = new Router();
// Route to serve index.html
router.get("/", async (context) => {
try {
const indexHtml = await Deno.readTextFile("./index.html");
context.response.headers.set("Content-Type", "text/html");
@cablehead
cablehead / iter.nu
Created September 4, 2024 23:52
nushell - discord - bot - bookmarklet prototype
use xs2.nu *
.cat | stateful filter {messages: {} marked: {}} {
|state frame|
if $frame == null {
return {out: $state}
}
if $frame.topic != "discord.ws.recv" { return {} }
let message = ($frame | .cas $in.hash | from json)
#!/usr/bin/env bash
# select a tmux window (ordered by recent used) with fzf and focus
tmux list-windows -F "#{window_activity} #{window_index} #{window_name}" |
sort -nrk 1 |
cut -d' ' -f2- |
fzf |
cut -d' ' -f1 |
xargs -I {} tmux select-window -t ':{}'