This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule RedBlackTree do | |
| @type color :: :red | :black | |
| @type tree :: nil | {color, any, tree, tree} | |
| @spec insert(tree, any) :: tree | |
| def insert(nil, value), do: {:black, value, nil, nil} | |
| def insert(tree, value) do | |
| {_, new_value, new_left, new_right} = do_insert(tree, value) | |
| {:black, new_value, new_left, new_right} | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule FlowSkiplist do | |
| @chunk_size 1000 | |
| def new(data) do | |
| data | |
| |> Flow.from_enumerable() | |
| |> Flow.partition() | |
| |> Flow.reduce(fn -> [] end, fn elem, acc -> [elem | acc] end) | |
| |> Enum.to_list() | |
| |> List.flatten() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "mcpServers": { | |
| "github": { | |
| "command": "npx", | |
| "args": ["-y", "@modelcontextprotocol/server-github"], | |
| "env": { | |
| "GITHUB_PERSONAL_ACCESS_TOKEN": "..." | |
| } | |
| }, | |
| "sequential-thinking": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Nghenhan.MarketDataValidator do | |
| @moduledoc """ | |
| Validates market data completeness and quality by reading from the landing zone. | |
| Runs as a separate service that can identify data quality issues without | |
| affecting raw data collection. | |
| """ | |
| use GenServer | |
| require Logger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =ARRAYFORMULA( | |
| SUM( | |
| IF( | |
| INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(),4), "1", "") & "2:" & SUBSTITUTE(ADDRESS(1,COLUMN(),4), "1", "") & COUNTA($A:$A)) = "x", | |
| INDIRECT("$R2:$R" & COUNTA($A:$A)) / | |
| INDIRECT("$Q2:$Q" & COUNTA($A:$A)), | |
| 0 | |
| ) | |
| ) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Nghenhan.LandingZone do | |
| @moduledoc """ | |
| Hot Landing Zone implementation with fast recovery using segmented logs, | |
| separate index files, and checkpoints. | |
| """ | |
| use GenServer | |
| require Logger | |
| @checkpoint_interval 300_000 # 5 minutes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "packages": [ | |
| "rustup@latest", | |
| "libiconv@latest", | |
| "rustc-wasm32@latest", | |
| "wasmtime@latest", | |
| "cmake@latest" | |
| ], | |
| "shell": { | |
| "init_hook": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule ExactlyOnce do | |
| use GenServer | |
| require Logger | |
| # State will store processed event IDs and their status | |
| defmodule State do | |
| defstruct processed_events: %{}, | |
| processing_timeouts: %{}, | |
| retry_interval: 5_000, | |
| processing_timeout: 30_000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createDataType<T extends { type: string }>() { | |
| return new Proxy( | |
| {}, | |
| { | |
| get(_, type: string) { | |
| return (data = {}) => ({ type, ...data }); | |
| }, | |
| } | |
| ) as { | |
| [K in T['type']]: ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule DiscordCollector.FLAMEDecorator do | |
| @moduledoc """ | |
| Provides FLAME function decorators that wrap functions to run in FLAME pools. | |
| ## Usage | |
| defmodule MyModule do | |
| use DiscordCollector.FLAMEDecorator | |
| @decorate flame(MyApp.Pool) |