Skip to content

Instantly share code, notes, and snippets.

@netanel-haber
netanel-haber / codex-termux-fix.md
Last active May 1, 2026 23:10
Fix OpenAI Codex CLI on Termux (Android)

Fix: OpenAI Codex CLI on Termux

codex login --device-auth fails with:

error sending request for url (https://auth.openai.com/api/accounts/deviceauth/usercode)

Cause: Codex ships a musl-linked binary that expects /etc/resolv.conf (DNS) and /etc/ssl/certs/ca-certificates.crt (TLS) — neither exist on Termux.

Verify:

@netanel-haber
netanel-haber / install_zsh.sh
Last active April 26, 2026 11:22
Install zsh on a machine, without sudo
#!/bin/bash
set -euo pipefail
set -x # log every command
NCURSES_VERSION=6.4
NCURSES_SOURCE="ncurses-$NCURSES_VERSION"
ZSH_VERSION=5.9
ZSH_SOURCE=zsh_source
ZSH_INST=$HOME/zsh_inst
import subprocess, importlib.util
from pathlib import Path
def missing_typed() -> set[str]:
mypy_output = subprocess.run(["python", "-m", "mypy", "."], text=True, capture_output=True).stdout.splitlines()
return {l.split('"')[1] for l in mypy_output if "missing library stubs or py.typed" in l}
for pkg in missing_typed():
if (loc := importlib.util.find_spec(pkg)) and loc.submodule_search_locations:
Path(next(iter(loc.submodule_search_locations)), "py.typed").touch()
@netanel-haber
netanel-haber / repo-rinse.sh
Last active August 13, 2023 11:45 — forked from nicktoumpelis/repo-rinse.sh
add --remote
# https://stackoverflow.com/questions/3796927/how-do-i-git-clone-a-repo-including-its-submodules/56833308#comment132351771_56833308
git submodule foreach --recursive git clean -xfd
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive --remote
@netanel-haber
netanel-haber / python_threads_http.py
Created September 11, 2021 19:46
Python Has Threads!
from requests import Session
from time import time
from functools import partial
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
import requests
def fetch(i, fetch_object=requests):
return fetch_object.get(f"https://jsonplaceholder.typicode.com/todos/{i}").json()[
"id"
class MaxStack {
stack = [];
checkMaxStack(popped) {
if (this.max === popped)
this.stack.pop();
}
feedMaxStack(values) {
const largest = Math.max(...values);
if (!this.max) {
// https://stackoverflow.com/questions/61411776/is-js-native-array-flat-slow-for-depth-1
// [--jsperf is down--] https://jsperf.com/flat-array-depth-1 - I added this jsperf benchmark after this gist was created and the SO question was asked.
let TenThouWideArray = Array(1000).fill().map(el => Array(10).fill(1));
let TenThouNarrowArray = Array(10).fill().map(el => Array(1000).fill(1));
let TenMilWideArray = Array(10000).fill().map(el => Array(1000).fill(1));
let TenMilNarrowArray = Array(100).fill().map(el => Array(100000).fill(1));
let benchmarks = { TenThouWideArray, TenThouNarrowArray, TenMilWideArray, TenMilNarrowArray };
let implementations = [