001 Notes

AI Wrote Everything Except This

Exploiting $100 worth of Codex

Necromancing My Incomplete Projects

  • Every project in this blog was basically half-done and unoptimized. Workable for my needs, but more like scripts than proper projects.
  • One night, in an inebriated state, I took a chance and got myself Codex. Behold the necromancer: the thing that transformed these projects into something I am not ashamed to share anymore, I guess.
  • It was not one-shot. It went through many versions, ups, and downs to be at this state.
  • This article is probably the only thing that is not vibe-coded. Pure human effort, like a caveman.

Let this be the dumping yard of all the goods and bads I came across.

Codex & Projects

  • AI is a workhorse. Give it proper instructions and it will kind of complete the whole thing like a junior engineer.
  • Not that it cannot suggest things. It does, but it is not always correct. So bois, there is still scope for us to hold a job for some more time.

Optimized Python Backtester

  • One of the projects I did was creating a backtesting engine: Opening Range Breakout.
  • The first draft was simple Python code. It was an actual backtesting engine, but not optimized.
  • We went from Python to Rust, and something like 100x or more speed over the first draft.
  • Obviously it was not Codex’s choice to do that. I had to tell it. But the major point was: if there is something quantifiable and verifiable, base the logic around that in the prompt or AGENTS.md.
  • For instance, generated by ChatGPT itself:
- Performance loop: write -> benchmark -> hotspot -> rewrite -> benchmark.
- Do 1-2 passes by default; continue only while gains are material or target performance is unmet.
- Stop if complexity outweighs benefit, gains fall below ~10-15%, or bottleneck is outside touched code.
- For huge jobs, benchmark and optimize one representative case before scaling out.
- Document benchmarks, bottlenecks, optimizations, and remaining gaps.
  • So I kept getting hotspots and suggestions about solving them. Not every optimization was good, but it never progressed blindly. It benchmarked every change it made, and if it regressed, it simply discarded it.
  • I will update the blog with exact things, but I think it started out simple, optimized there, used GPU, used NumPy, optimized GPU kernels, switched to Rust, moved the machine to AMD Ryzen 3D with 96MB of cache, went to HFT-like optimizations rather than GPU-based ones, got way faster because all operations for candles could be done in one shot, and then added SIMD.

GUI for Projects Listed Here

  • Since I hate Electron and wanted native desktop, I had all the GUI in PyQt for the projects listed here.
  • Creating GUI with Codex was a bit difficult, I would say. Every time it generated UI that was card-based, mobile-optimized, with huge cards, borders, and materialized everything.
  • Initially I went to Gemini to get better UI wireframes, and genuinely I found it to be better.
  • But certain instructions helped create better UI. UI skills as generated by ChatGPT:
## Layout baseline
Treat `1920x1080` as the baseline contract.

At baseline resolution:
- primary navigation must remain visible
- key operational content must fit without obvious breakage
- headers, toolbars, and margins must stay compact
- layout must look intentionally designed, not barely surviving

For larger displays:
- reveal more structure, more columns, more panes, more metadata
- do not merely enlarge padding or center a narrow layout in empty space

For smaller windows:
- degrade gracefully using splitters, scroll areas, collapsible panes, tab folding, and hidden secondary metadata
- preserve the main workflow first

Use layouts, stretch, min/max/preferred sizing, and splitters deliberately.
Do not rely on fixed geometry hacks.

## UI design rules
Prefer:
- flat or GTK-like visual language
- compact spacing
- restrained borders
- subtle pane grouping
- dense but readable presentation
- thin toolbars and compact controls
- semantic color only when meaning exists

Avoid:
- mobile-style spacing
- oversized cards
- giant headers
- decorative whitespace
- loud gradients
- glassmorphism
- shadow-heavy floating panels

If cards are used:
- keep them flat or lightly separated
- keep border radius modest
- group by function, not decoration

## State visibility
The UI should always make state obvious.

Expose clearly:
- current page/section/context
- active workspace, account, project, or mode
- selected filters and scope
- stale vs live state
- loading / ready / failed state
- backend execution mode when relevant, such as GPU vs CPU
- AI backend status when AI features exist

Prefer:
- compact context strips
- breadcrumb-like state bars
- pane headers with inline state
- small visible status indicators close to where the work happens
  • Still, sometimes it was not adhering to it. So simply take a screenshot of the offending elements and ask Codex to fix it in the way you want. Damn, I got a PhD in screen-snipping in Windows. :/ :/

Performance of GUI

  • Codex does not seem to do async things by default. Generally it does the job on the main thread itself, idk why. In all the projects, the only QThreads that existed were my own, or I had to ask Codex to do it.
  • Again, ChatGPT skill to save ourselves the agony:
### Main thread discipline
Never perform heavy work on the main UI thread.

Move off the main thread:
- file I/O
- network I/O
- long database work
- parsing
- expensive transformations
- chart recomputation
- image processing
- AI inference
- repeated bulk model rebuilds

The main UI thread should focus on:
- input handling
- layout
- paint
- lightweight state application

Do not put expensive work in:
- `paintEvent`
- resize handlers
- high-frequency timers
- repeated filter/search callbacks
- full-page refresh loops

Other Nuances: GUI

  • Codex does silently work in the background, so explicitly ask it that whatever happens in the background should be shown on UI: status bar, progress bar, anything like that.

Code

  • For some reason unknown to me, Codex likes to write a lot of code. Too much abstraction, too much overengineered for even a small thing, at least in Python.
  • While writing Rust, Codex seems a pretty simple bloke. Structs and impls are all it cares about generally.
  • I really have not opened and checked what Codex has written since months. Just what it does and whether that is satisfactory or not.
  • Here is another ChatGPT AGENTS.md section:
## Code
- Prefer small, focused functions and explicit names.
- Naming should follow project or language conventions; if not defined locally, use `PascalCase` for classes, `camelCase` for methods/functions, and `snake_case` for variables.
- Prefer vertical alignment for grouped declarations/assignments using `:`, `=`, or similar separators when it improves readability and matches local style.
- Do not reformat unrelated code only to enforce alignment.
- Do not add dependencies or abstractions unless necessary.
- Do not introduce pattern-heavy indirection such as providers, factories, DI containers, or service locators unless clearly justified by real complexity.
- Do not create abstractions for hypothetical future use.
- Do not create interfaces, base classes, wrappers, or generic utilities unless there is a clear current need.
- Do not swallow errors silently.
- Add actionable logging at failure-prone boundaries.

Codex & Blog

  • Well, even the articles here are COMPLETED by Codex.
  • What I wrote was a template, a skeleton of things I wanted to be in the article, and then asked Codex to write it like it is writing a blog. Include examples wherever necessary.
  • For instance, the DSA State Space Exploration article’s first mental model structure given to Codex was like this:
I want you to explain the mental model with this as base:
- You are at a place in world. That is your state.
- Based on certain condition, you can take several actions in this state
- Based on other condition, you can choose to go other state, where you going to do the same action.

Draw visual diagrams.
Give examples, like a Matrix is the world, then cell is your state. Now given condition that you can move in X or Y direction, your next state will going in that certain direction.
Extend the example to trees, arrays etc.
  • So it simply expanded everything and created the mental model. Obviously it went through iterations, but no more writing this much. Just a small batch, it mapped it properly once it had been told how to do it.
  • Hence, you can see long long articles here. xD I am too lazy to write them completely.