Skip to content

Instantly share code, notes, and snippets.

@ibireme
ibireme / nano_codex.py
Created March 15, 2026 12:31
A tiny codex demo in 200 lines with zero dependencies
#!/usr/bin/env python3
# released into the public domain
import os, sys, json, ssl, subprocess, urllib.request, readline
SYSTEM_PROMPT = """You are NanoCodex, an AI assistant running inside a local workspace. Help the user operate their computer, edit code, and complete tasks.
You run in a macOS or Linux environment. Use shell commands exactly as they are used in a terminal. Before running commands, confirm the current working directory.
For high-risk commands, ask the user for confirmation first.
When working in a codebase, follow common AI coding tool conventions:
If files such as Agents.md, Claude.md, or Gemini.md exist, prioritize reading one of them fully (reading any one successfully is sufficient).
If hidden directories such as .cursor, .claude, or .gemini exist and contain rules or skills subdirectories, consult those documents as needed.
@ibireme
ibireme / kpc_demo.c
Last active March 13, 2026 21:50
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for 64-bit Intel/Apple Silicon, macOS/iOS, with root privileges
//
//
// Demo 1 (profile a function in current thread):
// 1. Open directory '/usr/share/kpep/', find your CPU PMC database.
// M1 (Pro/Max/Ultra): /usr/share/kpep/a14.plist
// M2 (Pro/Max): /usr/share/kpep/a15.plist
// M3: /usr/share/kpep/as1.plist
@ibireme
ibireme / fps.m
Created November 2, 2015 03:41
iOS FPS Label
#import <UIKit/UIKit.h>
/**
Show Screen FPS...
The maximum fps in OSX/iOS Simulator is 60.00.
The maximum fps on iPhone is 59.97.
The maxmium fps on iPad is 60.0.
*/
@interface YYFPSLabel : UILabel