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
@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 February 20, 2025 06:45
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"
// ==UserScript==
// @name Download songs
// @description Download songs from a specific website
// @namespace Violentmonkey Scripts
// @match REDACTED
// @version 0.1
// @author Noah Betzen
// @grant none
// ==/UserScript==
@Nezteb
Nezteb / jai_and_odin.md
Created September 30, 2023 04:03
A detailed breakdown of @SentientCoffee's opinions on Jai and Odin from the Odin Discord.

what i wish jai had:

  • better "standard library" (odin's core+vendor libraries/jai's compiler modules)

    odin's interface for things is very intuitive and very well designed, it doesn't take long to find what you're looking for, and it's very consistent. for example, strings.builder_make(), strings.builder_init(), strings.builder_destroy(), etc. meanwhile in jai you have things like String_Builder procs: init (which could refer to any number of procs because overloading) print_to_builder, free_buffers/reset, append, etc. (there are more examples like this in other modules.) once you find what you're looking for, it works great, but odin's core library discoverability is top notch (especially with https://pkg.odin-lang.org/ exisiting)

  • slice syntax

jai has "array views" which are exactly like odin slices. but odin's way of handling them with the python syntax makes it 10x more usable, rather than having to use array_view(*view, 0, count) everywhere, and lets you not depend on pointer arithmetic like jai

# Mac App Store
# mas "1Password", id: 443987910
# Taps
tap "1password/tap"
tap "ankitpokhrel/jira-cli"
tap "derailed/k9s"
tap "gcenx/wine"
tap "homebrew/cask-versions"
tap "homebrew/services"