Skip to content

Instantly share code, notes, and snippets.

Setup: codex wrapper for Azure OpenAI

This wrapper checks for an Azure OpenAI API key before launching codex. If the key is missing or insecure, it falls back to the openai profile.

1. Configure codex

Create ~/.codex/config.toml with the following content:

# ~/.codex/config.toml
@pmav99
pmav99 / cubed_sphere.py
Created November 21, 2024 22:36 — forked from darothen/cubed_sphere.py
Cubed Sphere Mesh Generation and Plotting
from itertools import product
import numpy as np
INV_SQRT_3 = 1.0 / np.sqrt(3.0)
ASIN_INV_SQRT_3 = np.arcsin(INV_SQRT_3)
def gaussian_bell(xs, ys, xc=0., yc=0., xsigma=1., ysigma=1.):
""" Compute a 2D Gaussian with asymmetric standard deviations and
@pmav99
pmav99 / GSHHG_Crude.txt
Created October 2, 2024 09:47
Equal Earth Projections comparison
count mean std min 0.01% 0.1% 1% 5% 50% 95% max
Sphere_Sinusoidal 763.0 1.914681e+11 2.372329e+12 12710.243678 19863.381206 84241.618957 319912.537468 736928.604246 7.063695e+06 3.933282e+10 5.037316e+13
World_Sinusoidal 763.0 1.916041e+11 2.374258e+12 12807.187297 19925.034360 83985.657924 321332.775607 734977.773185 7.105145e+06 3.955987e+10 5.047489e+13
Sphere_Mollweide 763.0 1.910515e+11 2.370221e+12 11428.973514 18679.709621 83936.334582 321039.742256 730216.371168 7.080316e+06 3.922586e+10 5.037068e+13
World_Mollweide 763.0 1.914797e+11 2.375534e+12 11454.594055 18721.584280 84124.496300 321759.423300 731853.311448 7.096188e+06 3.931379e+10 5.048360e+13
Sphere_Eckert_VI 763.0 1.914801e+11 2.372390e+12 10075.406577 17429.301224 83614.353046 317443.145553 73206
@pmav99
pmav99 / append_to_parquet.ipynb
Last active September 8, 2023 08:18
append to parquet files
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmav99
pmav99 / split_quads.md
Last active August 2, 2022 07:42
Split quads using numpy

image

image

import numpy as np

face_nodes = np.array([
    [1, 2, 6, np.nan],
    [1, 6, 5, np.nan],
@pmav99
pmav99 / dotted_to_nested.py
Created November 28, 2021 12:29
Convert a "dotted" dictionary to a nested one
from functools import reduce
from typing import Any
from typing import Dict
def merge(a, b, path=None):
""" Merge dictionary a into b (in-place)"""
# source: https://stackoverflow.com/a/7205107/592289
if path is None: path = []
for key in b:
@pmav99
pmav99 / transform_epsg_4326_to_3857_with_pyproj.py
Created December 18, 2020 23:10
Convert epsg:4326 to epsg:3857 using the latest version of pyproj
import numpy as np
import pyproj
# Use the "new" numpy API for the random number generation (requires numpy >=1.17)
rng = np.random.default_rng(seed=1)
# Create arrays with random points
no_points = 5
longitudes = rng.uniform(low=10, high=20, size=no_points)
latitudes = rng.uniform(low=33, high=45, size=no_points)
@pmav99
pmav99 / gatttool-polar-h10.txt
Created November 24, 2020 20:32 — forked from fphammerle/gatttool-polar-h10.txt
bluez gatttool: receive heart rate notifications from polar h10 (bluetooth heart rate sensor)
$ sudo hcitool lescan
AA:BB:CC:DD:EE:FF Polar H10 ABCDEFGH
$ gatttool -t random --device=AA:BB:CC:DD:EE:FF --interactive
[AA:BB:CC:DD:EE:FF][LE]> connect
Attempting to connect to AA:BB:CC:DD:EE:FF
Connection successful
[AA:BB:CC:DD:EE:FF][LE]> primary
attr handle: 0x0001, end grp handle: 0x0009 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000a, end grp handle: 0x000d uuid: 00001801-0000-1000-8000-00805f9b34fb
@pmav99
pmav99 / test_tf.py
Last active October 22, 2019 13:33
Simple tensorflow test
#!/usr/bin/env python3
import datetime
import numpy as np
import tensorflow as tf
# Processing Units logs
log_device_placement = True
@pmav99
pmav99 / verify_password.py
Created October 21, 2019 09:36
Verify jupyter / ipython password hashlib
import hashlib
import sys
if len(sys.argv) != 3:
sys.exit("Usage: python3 verify.py hash passphrase")
provided_hash = sys.argv[1]
passphrase = sys.argv[2]
salt = provided_hash.split(":")[1]