Skip to content

Instantly share code, notes, and snippets.

View nrbnlulu's full-sized avatar

ניר nrbnlulu

  • Israel, Jerusalem
  • 13:26 (UTC +03:00)
View GitHub Profile
@nrbnlulu
nrbnlulu / generic_qml_model_generator.py
Last active August 3, 2022 14:01
Qt Qml Generic Model
import typing
import attrs
from attrs import define, NOTHING, asdict
from typing import TypeVar, Any
from src.tools.utils import to_camel_case
from qtpy import QtCore as qtc
from src.tools.exceptions import ModelError
T = TypeVar("GenericType")
RoleDefined = TypeVar("RokeDefined")
@nrbnlulu
nrbnlulu / pyside_gql_subscriber.py
Last active November 24, 2022 07:22
graphql-transport-ws implementation with `QWebSocket`
import uuid
from dataclasses import dataclass, asdict, field, is_dataclass
import json
from qtpy import QtCore as qtc, QtWebSockets as qtws, QtNetwork as qtn
from typing import NamedTuple, Optional, NewType, Union, Any
from tzvui.network.client import HOST, PORT
from tzvui.qthacks import slot
from functools import partial
from timeit import timeit
from PySide6.QtCore import QCoreApplication, QObject, Slot
from qtgql import slot
def manual():
class ManualTyping(QObject):
@Slot(str, int, result="int")
@nrbnlulu
nrbnlulu / Main.qml
Last active May 27, 2024 16:50
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;
@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 / 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 / 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 / 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 / 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 _