This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * demi-compact: a poor man's compaction. | |
| * | |
| * Instead of summarizing history into a single block, it truncates tool | |
| * call inputs (to 80 chars) and drops tool result outputs entirely from | |
| * messages older than the cutoff recorded when the user runs | |
| * `/demi-compact`. The fact that a tool was called is preserved, but the | |
| * verbose I/O that dominates token usage is stripped. User/assistant | |
| * text remains fully intact. | |
| * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"; | |
| import { Type } from "@sinclair/typebox"; | |
| import { spawn } from "node:child_process"; | |
| import { createWriteStream, mkdirSync, rmSync, existsSync, readdirSync, unlinkSync } from "node:fs"; | |
| import { join } from "node:path"; | |
| import { homedir } from "node:os"; | |
| const DISPATCH_LOG_DIR = join(homedir(), ".pi", "agent", "dispatch"); | |
| function ensureLogDir(): void { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Create frags directory if it doesn't exist | |
| FRAG_DIR="$HOME/frags" | |
| mkdir -p "$FRAG_DIR" | |
| # Generate timestamp for filename | |
| TIMESTAMP=$(date +"%Y%m%d_%H%M%S") | |
| FILENAME="$FRAG_DIR/frag_${TIMESTAMP}.txt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pathlib | |
| import string | |
| import itertools | |
| import random | |
| from typing import Callable | |
| roots = "select 100 as id" | |
| def sql(nodes): | |
| return "UNION ALL".join(["select 100 as id from {{ ref('%s') }}" % n for n in nodes]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/homebrew/bin/python3 | |
| import datetime | |
| import sys | |
| import os | |
| from pathlib import Path | |
| home = os.path.expanduser('~') | |
| fname = f"{home}/whatidid" | |
| if not os.path.isfile(fname): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import requests | |
| import collections | |
| headers = { | |
| 'Accept': 'application/vnd.github+json', | |
| 'Authorization': 'Bearer ' + os.getenv('GITHUB_API_TOKEN', ''), | |
| 'X-GitHub-Api-Version': '2022-11-28', | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import Counter | |
| from itertools import combinations | |
| types = [1,2,3,4] | |
| # creatures have 2 of the 4 types | |
| # so there are c(4,2) = 6 creatures | |
| creatures = list(combinations(types, 2)) | |
| # there are four creatures in each ocean |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pathlib | |
| import collections | |
| import jinja2 | |
| import graphlib | |
| class Engine: | |
| current = None | |
| graph = collections.defaultdict(lambda: dict(deps=[], compiled=None, config={})) | |
| env = jinja2.Environment( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| from random import randint | |
| # make some dumb fake data | |
| def make_row(r): | |
| r = randint(1, 200) | |
| s = [randint(r - min(r - 1, 15), r + 15) for _ in range(randint(1,6))] | |
| return [r, s] | |
| rows = [make_row(r) for r in range(500_000)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # So you want to do machine learning in elixir on a fresh GCP VM with a GPU? | |
| === setup a VM === | |
| 1. chose a gpu (T4), make sure you use debian 11 bullseye and the right region | |
| 2. dont use the default boot disk | |
| 3. do change the boot disk to have 50GB of space | |
| 4. get yourself a bunch of ram (for re-training BERT with 250 text samples 15Gb wasn't enough) | |
| 5. ssh in: | |
| gcloud compute ssh instance-6 |
NewerOlder