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 App.Repo.Migrations.CreateExtensionTimescale do | |
| use Ecto.Migration | |
| def up do | |
| # enable extension | |
| execute("CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE") | |
| # remove primary key constraint | |
| execute("ALTER TABLE events DROP CONSTRAINT events_pkey CASCADE") | |
| # create hypertable | |
| execute("SELECT create_hypertable('events', 'created_at')") |
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.BinanceCollector.Supervisor do | |
| use Supervisor | |
| def start_link(opts) do | |
| Supervisor.start_link(__MODULE__, opts, name: __MODULE__) | |
| end | |
| @impl true | |
| def init(_opts) do | |
| children = [ |
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 |