Skip to content

Instantly share code, notes, and snippets.

View daedalus's full-sized avatar

Darío Clavijo daedalus

View GitHub Profile
import json
import sys
from subprocess import getoutput as run_shell
from urllib.request import Request, urlopen
MODEL = "gpt-5.6"
CONTEXT_WINDOW_TOKENS = 1_050_000
endpoint_url = sys.argv[1]
history = []
@tosh
tosh / agent.py
Created July 22, 2026 13:19
agent in 9 lines python
import json,sys;from subprocess import getoutput as sh;from urllib.request import Request as R,urlopen
url=sys.argv[1];h=[];b=dict(model="gpt-5.6",input=h,tools=[dict(type="custom",name="sh")])
while p:=input("> "):
h+=[dict(role="user",content=p)];H={"Content-Type":"application/json"}
while True:
o=(r:=json.load(urlopen(R(url,json.dumps(b).encode(),H))))["output"]
h+=o;c=[i for i in o if i["type"]=="custom_tool_call"];z=r["usage"]["total_tokens"]/10500
if not c:print(o[-1]["content"][0]["text"],f'\n[{z:06.3f}%]');break
h+=[dict(type="custom_tool_call_output",call_id=i["call_id"],output=sh(i["input"])) for i in c]
"""
Minimal verification: is Rio-3.5-Open-397B ≈ α·Nex-N2-Pro + (1-α)·Qwen3.5-397B-A17B?
Strategy: download the safetensors header via HTTP range request, then fetch
only the specific tensor bytes we need. No multi-GB shard downloads.
"""
import json
import struct
import numpy as np
@ruvnet
ruvnet / ruvllm_sparse_attention_report.md
Last active June 21, 2026 21:24
ruvllm_sparse_attention: Subquadratic Sparse Attention for Edge LLM Inference on Hailo-10H Pi 5 Cluster

ruvllm_sparse_attention: Subquadratic Sparse Attention for Edge LLM Inference

What This Is (Simple Version)

AI language models are slow on small computers — not because of the model weights, but because of attention: the mechanism that lets every word look at every other word in the text. When you double the text length, attention gets four times harder, not twice.

ruvllm_sparse_attention fixes this by teaching the model to be selective. Instead of every word looking at every other word, it looks at:

  • The words closest to it (recent context)
  • A few anchor words at the start (global signals)
@alufers
alufers / copy_fail.c
Last active May 4, 2026 14:47
copy fail c rewrite
// Compile: zig cc -target aarch64-linux-musl -static exp.c -o main_aarch64
// Embedded binary is for aarch64, the commented out is the original x86_64 one.
#define _GNU_SOURCE /* See feature_test_macros(7) */
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
@alganet
alganet / c89cc.sh
Last active July 14, 2026 00:00
c89cc.sh - standalone C89/ELF64 compiler in pure portable shell
#!/bin/sh
# ISC License
# Copyright (c) 2026 Alexandre Gomes Gaigalas <alganet@gmail.com>
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
#!/usr/bin/env python
import os
import sys
import gzip
import itertools
from struct import pack, pack_into, unpack, unpack_from, calcsize
from binascii import hexlify, unhexlify
from subprocess import Popen, PIPE

We want to show that any divisor $d | M(n) = 2^n-1$ is a Fermat pseudo-prime for base $2^{n/2}$. That would mean that $\big( 2^{(n/2)} \big)^{d-1} \equiv 1 \pmod d$. Assume $n$ is even and $n&gt;4$.

  1. $M(n) \equiv 2^n - 1 \equiv 0 \pmod d$ (given)
  2. $2^n \equiv 1 \pmod d$ (restatement of step (1))
  3. $\left( 2^{(n/2)}\right)^{d-1} \equiv 2^{\left(\frac {n(d-1)} 2 \right)} \equiv \left(2^n\right)^{\left( \frac {d-1} 2 \right)} \equiv 1 \pmod d$ (step (2), $d-1$ is even)
  4. $(2^{n/2})^{d-1} \equiv 1 \pmod d \rightarrow$ $d$ is pseudo-prime in base $2^{n/2}$ (definition)

Thus, $d$ is a Fermat pseudo-prime for base $2^{n/2}$

@thesamesam
thesamesam / xz-backdoor.md
Last active July 17, 2026 18:23
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Update: I've disabled comments as of 2025-01-26 to avoid everyone having notifications for something a year on if someone wants to suggest a correction. Folks are free to email to suggest corrections still, of course.

Background

#! /bin/bash
# Modified to run both (redudantly, yes, I know, I am paranoid, you should be too) checks
#
set -eu
# find path to liblzma used by sshd
path="$(ldd $(which sshd) | grep liblzma | grep -o '/[^ ]*')"
echo 'Check one: does it even exist?'
# does it even exist?
if [ "$path" == "" ]