Skip to content

Instantly share code, notes, and snippets.

@nrbnlulu
nrbnlulu / dataloader.dart
Created March 29, 2026 15:38
dart dataloader
import 'dart:async';
typedef LoaderFn<K, T, E> = Future<Map<K, Result<T, E>>> Function(List<K> keys);
class DataloaderConfig {
const DataloaderConfig({
this.maxBatchSize = 100,
this.delayBeforeResolve = const Duration(milliseconds: 100),
});
@nrbnlulu
nrbnlulu / env.dart
Last active March 24, 2026 08:04
dart env
class Env {
Map<String, String> _env = {};
static final Env instance = Env._();
Env._() {
// read cwd .env
_env = Platform.environment.map((key, value) => MapEntry(key, value));
final file = File('.env');
// coverage:ignore-start
@nrbnlulu
nrbnlulu / code review instructions backend.md
Last active February 25, 2026 07:30
code review instructions backend

Write a codereview by diffing with the main branch.

  • output in markdown format
  • include these catagories: bug, nit, typo, DX (bad api's), UX (adapters, graphql etc), code-smell
  • always check whats the aproach of the repo to do things and review based on that.
  • sort by catagory, then severity
  • write the review to review-__diff_main.md
@nrbnlulu
nrbnlulu / codereview.md
Created February 23, 2026 07:37
code review instructions for flutter + rust

check @AGENTS.md

Code Review Guidelines: Flutter + Rust (FRB) Bridge

This guide is designed for AI Agents performing automated code reviews on a Flutter library that utilizes flutter_rust_bridge (FRB). The goal is to ensure safety, performance, and seamless DX (Developer Experience) across the FFI boundary.


🛠 Review Methodology

@nrbnlulu
nrbnlulu / a.md
Last active September 12, 2025 13:44
אפיון פיקלול 2

סטטוס מפתוחים

בתור קאגמ \ סמבץ CCT ארצה לראות סטטוס עדכני של כלל המפתוחים לפי אתר או מסגרת + סטטוס תקינות בהתאם לתקלות הפתוחות על המפתוחים. ארצ לראות גם איזה מפתןחים ב"אוויר" יש לי ע"מ שאוכל לתעדף במקרה הצורך

סטטוס האזנות

בתור קאגמ ארצה לראות סהכ מכשירים בבעלות מבצעית שלי ממי קבלתי אותם וכן לגבי האזנות

@nrbnlulu
nrbnlulu / bench.py
Created August 18, 2025 09:06
storage efficiency benchmark between messagepack and json + gzip
import gzip
import json
from pathlib import Path
import msgspec
raw = """
{"abilities":[{"ability":{"name":"overgrow","url":"https://pokeapi.co/api/v2/ability/65/"},"is_hidden":false,"slot":1},{"ability":{"name":"chlorophyll","url":"https://pokeapi.co/api/v2/ability/34/"},"is_hidden":true,"slot":3}],"base_experience":64,"cries":{"latest":"https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/latest/1.ogg","legacy":"https://raw.githubusercontent.com/PokeAPI/cries/main/cries/pokemon/legacy/1.ogg"},"forms":[{"name":"bulbasaur","url":"https://pokeapi.co/api/v2/pokemon-form/1/"}],"game_indices":[{"game_index":153,"version":{"name":"red","url":"https://pokeapi.co/api/v2/version/1/"}},{"game_index":153,"version":{"name":"blue","url":"https://pokeapi.co/api/v2/version/2/"}},{"game_index":153,"version":{"name":"yellow","url":"https://pokeapi.co/api/v2/version/3/"}},{"game_index":1,"version":{"name":"gold","url":"https://pokeapi.co/api/v2/version/4/"}},{"game_index":1,"version":{"name":"silver","url":"
@nrbnlulu
nrbnlulu / memoized_method.py
Created August 6, 2025 09:39
cached python method
def memoized_method[**Ps, T](hash_fn: Callable[Ps, int] | None = None) -> Callable[[Callable[Ps, T]], Callable[Ps, T]]:
def wrapper(fn: Callable[Ps, T]) -> Callable[Ps, T]:
@functools.wraps(fn)
def ret(self, *args, **kwargs) -> T:
try:
cache: LRUCache[int, T] = self.__memoized_cache__
except AttributeError:
self.__memoized_cache__ = cache = LRUCache(capacity=100)
hash_key = hash_fn(self, *args, **kwargs) if hash_fn else hash((args, frozendict(kwargs.items())))
@nrbnlulu
nrbnlulu / pubsub.py
Created August 4, 2025 05:25
pubsub.py
from __future__ import annotations
import abc
import asyncio
import contextlib
import functools
import uuid
from collections.abc import AsyncIterator, Awaitable, Hashable, Iterable
from dataclasses import dataclass
from datetime import datetime, timedelta
@nrbnlulu
nrbnlulu / ffplay.py
Created June 26, 2025 11:22
ffplay playground for nvrs
#!/usr/bin/env python3
import os
import signal
import subprocess
import sys
import time
# Milesight NVR Configuration
NVR_IP = "shut"
RTSP_PORT = "554"
sealed class Result<T, E> {
const Result();
}
class Ok<T, E> extends Result<T, E> {
const Ok(this.value);
final T value;
}