Skip to content

Instantly share code, notes, and snippets.

View thanos's full-sized avatar

thanos vassilakis thanos

View GitHub Profile
@thanos
thanos / Membership-Filter-Comparison.md
Last active March 13, 2026 21:09
Membership Filter Comparison
Algorithm Deletions Merges Notes
Bloom Filter difficult yes - not dynamic classic
Cuckoo Filter YES YES modern
XOR Filter no no modern
Quotient Filter YES YES SSD friendly
CQF yes yes high performance
Binary Fuse Filter no no extremely compact modern
Ribbon Filter no no space efficient new design
@thanos
thanos / Quantile-Algorithm-Comparison.md
Last active March 13, 2026 19:05
Quantile Algorithm Comparison
Algorithm Strength
KLL General purpose
REQ Optimised for high quantiles (99th, 99.9th)
DDSketch Constant relative error across all quantiles
t-Digest Highly accurate at the tails
@thanos
thanos / Cardinality-Algorithm-Comparison.md
Last active March 13, 2026 18:50
Cardinality Algorithm Comparison
Algorithm Memory Accuracy Notes
HyperLogLog Small ~1% Industry standard
CPC Smaller Apache DataSketches; more complex
UltraLogLog Very compact Similar Modern variant; even more complex
Algorithm Memory Accuracy Notes
Count-Min Sketch Small ~1% Simple, widely supported
Misra-Gries Small Exact top-K Deterministic but less mergeable
Count Sketch Small Better for sparse data Handles negative updates
SpaceSaving Small Accurate Used in streaming systems
@thanos
thanos / virtual_field_option.ex
Created October 13, 2024 17:08
an example of a calculated virtual field used in a Many field's option for Backpex
options_query: fn query, _assigns ->
select_merge(
query,
[media],
%{label: fragment("concat(?, ', ', ?)", media.caption, media.original_file)}
)
end
@thanos
thanos / select_merge_example.ex
Created October 13, 2024 17:05
A select merge example for populating a virtual field
defmodule Answer do
use Ecto.Schema
schema "answer" do
field :word, :string
field :length, :integer, virtual: true
end
end
Repo.insert(%Answer{word: "SWANS"})
@thanos
thanos / xeni_travel_api_hotel_availability.sh
Last active August 26, 2023 17:26
Using Xeni Travel Api to fetch a hotel detail and it's availability
curl -X 'GET' "$XENI_API_HOST/api/accommodation_searches/accommodation?search_id=962c9315-0e35-45e3-b158-be10c860912d&property_id=40553&raw=true" \
-H "accept: application/json" \
-H "authorization: bearer: $XENI_TOKEN"
@thanos
thanos / xeni_search_hotel_availability.sh
Last active August 26, 2023 17:24
searching for hotel availability using the Xeni Travel API
curl -X 'POST' \
"$XENI_API_HOST/api/accommodation_searches/search" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "authorization: bearer: $XENI_TOKEN" \
-d '{
"check_in": "2023-08-27",
"check_out": "2023-08-30",
"destination_id": "bbc35c49-d2a7-431a-ac40-a4944c3a00e7",
"occupancies": [
@thanos
thanos / xeni_travel_api_set_envs.sh
Last active August 26, 2023 16:23
setting up environmental variables for XENI Trade API
export XENI_API_HOST="https://xenitravelapi-beta01.gigalixirapp.com"
export XENI_USER_EMAIL="some@email.com"
export XENI_USER_PASSWORD="some password"
export XENI_TOKEN=$(curl -X 'POST' $XENI_API_HOST/api/accounts/get_token \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{"user":{"email": "'"$XENI_USER_EMAIL"'", "password": "'"$XENI_USER_PASSWORD"'"}}' \
| sed "s/{.*\"token\":\"\([^\"]*\).*}/\1/g")
@thanos
thanos / xeni_travel_api_get_token.sh
Last active August 26, 2023 17:11
Get a token from the Xeni Travel API
curl -X 'POST' "$XENI_API_HOST/api/accounts/get_token" \
-H "accept: application/json" \
-H "content-type: application/json" \
-d '{"user":{"email": "'"$XENI_USER_EMAIL"'", "password": "'"$XENI_USER_PASSWORD"'"}}'
{"token":"eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ4ZW5pX3RyYXZlbF9hcGkiLCJleHAiOjE2OTI0MTA1ND9A"}