Skip to content

Instantly share code, notes, and snippets.

View Nezteb's full-sized avatar
💣
hello world'); DROP TABLE Statuses;--

Noah Betzen Nezteb

💣
hello world'); DROP TABLE Statuses;--
View GitHub Profile
# Test with different integer sizes
small_int = 42
medium_int = 123_456
large_int = 9_876_543_210
small_str = "42"
medium_str = "123456"
large_str = "9876543210"
Benchee.run(
@Nezteb
Nezteb / .rules
Created June 10, 2025 22:21
My own general rules file (some parts are pretty specific to Elixir, but hopefully mostly helpful
# General AI Notes
## The Golden Rule
When unsure about implementation details, ALWAYS ask the developer.
### Guidelines
- Add specially formatted anchor comments throughout the codebase, where appropriate, for yourself as inline knowledge that can be easily `grep`'d for.
- Use `AIDEV-NOTE:`, `AIDEV-TODO:`, or `AIDEV-QUESTION:` (all-caps prefix) for comments aimed at AI and developers.
@Nezteb
Nezteb / settings.jsonc
Last active June 6, 2025 17:26
Example ~/.config/zed/settings.json file for using OpenRouter models as OpenAI-compatible provider
{
"language_models": {
// No longer needed for OpenRouter: https://github.com/zed-industries/zed/pull/29496
// As of Zed v0.190.0-pre
// "openai": {
// "api_url": "https://openrouter.ai/api/v1",
// "available_models": [
// {
// "name": "google/gemini-2.5-pro-preview",
// "display_name": "Gemini 2.5 Pro Preview",
@Nezteb
Nezteb / test_helpers.ex
Created February 12, 2025 19:31
Elixir ExUnit helper for asserting that two maps (or structs) have equal values at the specified paths.
defmodule TestHelpers do
import ExUnit.Assertions, only: [assert: 2, flunk: 1]
@spec assert_nested_paths_equal(map(), map(), [atom()]) :: :ok
def assert_nested_paths_equal(map1, map2, paths) do
Enum.each(paths, fn path ->
with {:ok, value1} <- get_nested_field(map1, path),
{:ok, value2} <- get_nested_field(map2, path) do
assert value1 == value2,
"Path #{inspect(path)} differs: #{inspect(value1)} != #{inspect(value2)}"
@Nezteb
Nezteb / Deterministic_Simulation_Testing.exs
Last active February 5, 2025 20:03
Playing around with DST and ExUnit seed generation.
defmodule Simulator do
@moduledoc """
Handles parsing of different seed formats for simulation purposes.
Supports Git hashes, ISO8601 dates, and normal integer seeds.
Based on:
- https://docs.tigerbeetle.com/about/vopr/
- https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/HACKING.md#simulation-tests
- https://github.com/tigerbeetle/tigerbeetle/blob/main/src/testing/fuzz.zig#L72-L90
- https://github.com/whatyouhide/stream_data/blob/main/lib/ex_unit_properties.ex#L674-L689
#!/opt/homebrew/bin/bash
#
# A script that checks for previously failed tests, caches them to a file, and reruns only
# those tests again. Slightly more useful than `mix test --failed` alone because you can
# share/store your set of test failures however you want.
#
# TODO: Someday turn this into an ExUnit formatter: https://hexdocs.pm/ex_unit/ExUnit.Formatter.html
# - https://github.com/crertel/exunit_json_formatter/blob/master/lib/exunit_json_formatter.ex
# - https://github.com/findmypast-oss/exunit_json_formatter/blob/master/lib/exunit_json_formatter.ex
@Nezteb
Nezteb / opml.livemd
Created February 22, 2024 18:22
See discussion here: https://elixirforum.com/t/official-discourse-follow-plugin-for-elixirforum/61603 (requires Discourse auth because it's in a "members only" section)

ElixirForum Discourse RSS OPML Generator

Section

defmodule Discourse.OPML do
  defmodule Behaviour do
    @callback outline(list(String.t())) :: String.t()
  end
// ==UserScript==
// @name Intercept m3u8 streams
// @description Intercept XHR/fetch requests involving m3u8 stream identifiers
// @namespace Violentmonkey Scripts
// @match *://*/*
// @version 0.1
// @author Noah Betzen
// @grant none
// ==/UserScript==
@Nezteb
Nezteb / elixir-language-server-comparison.md
Last active June 7, 2025 12:23
Elixir Language Server Comparisons
@Nezteb
Nezteb / cache.sh
Last active October 6, 2023 20:02
A dumb shell command cacher.
# Usage `cache ls` or `cache ./myScript.sh`
cache() {
local expiry_minutes=20
local command_name="$1"
local command_hash=$(echo "$*" | md5sum | cut -d' ' -f1)
local cache_dir="$HOME/.cache/cli_cache"
local command_cache_dir="$cache_dir/$command_name"
local cache_file="$cache_dir/$command_hash"