Skip to content

Instantly share code, notes, and snippets.

{"help": "https://data.gov.il/api/3/action/help_show?name=datastore_search", "success": true, "result": {"include_total": true, "limit": 500, "records_format": "objects", "resource_id": "5c78e9fa-c2e2-4771-93ff-7f400a12f7ba", "total_estimation_threshold": null, "records": [{"_id":1,"סמל_ישוב":"0 ","שם_ישוב":"לא רשום ","שם_ישוב_לועזי":" ","סמל_נפה":0,"שם_נפה":"לא ידוע ","סמל_לשכת_מנא":0,"לשכה":" ","סמל_מועצה_איזורית":0,"שם_מועצה":null},{"_id":2,"סמל_ישוב":"3400 ","שם_ישוב":"חברון ","שם_ישוב_לועזי":" ","סמל_נפה":77,"שם_נפה":"חברון ","סמל_לשכת_מנא":11,"לשכה":"ירושלים ","סמל_מועצה_איזורית":0,"שם_מועצה":null},{"_id":3,"סמל_ישוב":"1347 ","שם_ישוב":"קצר א-סר ","שם_ישוב_לועזי":" ","סמל_נפה":62,"שם_נפה":"באר שבע ","סמל_לשכת_מנא":62,"לשכה":"באר שבע ","סמל_מועצה_איזורית":68,"שם_מועצה":"נווה מדבר"},{"_id":4,"סמל_ישוב":"1331 ","שם_ישוב":"כמאנה ","שם_ישוב_לועזי":" ","סמל_נפה":24,"שם_נפה":"עכו ","סמל_לשכת_מנא":20,"לשכה":"כרמיאל ","סמל_מועצה_איזורית":56,"שם_מועצה":"משגב"},{"_id":5,"סמל_ישוב":"3777 ","שם_ישוב":"סנסנה ","שם_יש
@nrbnlulu
nrbnlulu / generics_vs_inheritance.md
Last active May 12, 2024 08:22
Co/Cont/In(variance)

Covariant

parent :< child
child :< parent
i.e (fn args)

def eat(anima: Animal): ...

eat(Dog())

def bark(dog: Dog): ...
@nrbnlulu
nrbnlulu / dataclass_to_strawberry.py
Created May 7, 2024 05:46
Convert dataclasses to strawberry types
from collections.abc import Callable
from typing import Literal, dataclass_transform
import strawberry
from strawberry.type import get_object_definition
@dataclass_transform()
def dataclass_to_strawberry[T: type](kind: Literal["input", "type"] = "type") -> Callable[[T], T]:
def inner(cls: T) -> T:
@nrbnlulu
nrbnlulu / model_generator.py
Created February 25, 2024 18:31
Django Generic Relation "Table-per-relation"
from __future__ import annotations
import contextlib
import dataclasses
import enum
from importlib import import_module
from typing import TYPE_CHECKING, Generic, TypeVar, get_type_hints
from django.db import models
from django.utils.translation import gettext_lazy as _
@nrbnlulu
nrbnlulu / scratchpad_qtgql_new_architecture.cpp
Created January 14, 2024 20:21
Try to implement how to qtgqlcodegen would create types and their proxies in more verstile way.
template<typename T>
struct SubscribeAbleField;
template<typename T>
struct InSyncValue{
std::function<void(const T&)> on_changed;
void notify(const SubscribeAbleField<T>* sub){
on_changed(sub->value);
}
};
@nrbnlulu
nrbnlulu / ctest_pytest_runner.py
Created September 20, 2023 08:34
Run ctest tests from python
from __future__ import annotations
import json
import re
import subprocess
from pathlib import Path
import pytest
from typing_extensions import TypedDict
@nrbnlulu
nrbnlulu / catch2_testcase_runner.py
Created September 20, 2023 08:29
Find and run catch2 tests from python
from __future__ import annotations
import subprocess
from pathlib import Path
import pytest
from tests.conftest import IS_WINDOWS
exe_suffix = "exe" if IS_WINDOWS else "so"
@nrbnlulu
nrbnlulu / conanfile.py
Created August 28, 2023 07:46
conanfile for qt6
from __future__ import annotations
import contextlib
import glob
import os
import subprocess
from functools import cached_property
from pathlib import Path
from conan import ConanFile
@nrbnlulu
nrbnlulu / Main.qml
Last active September 28, 2023 17:39
QML live-reload
// every time this file is edited the loader will refresh it.
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import DogModule
Pane {
anchors.fill: parent;
Rectangle{
width:234;