Skip to content

Instantly share code, notes, and snippets.

View Harold2017's full-sized avatar
๐Ÿ˜ƒ

Harold Harold2017

๐Ÿ˜ƒ
View GitHub Profile
@Harold2017
Harold2017 / SQLAlchemy_JSON_column.md
Created October 17, 2025 05:32
how to correctly update json column with SQLAlchemy
"""
This is comment which describes why it's required to manually flag the modified context to make sure it gets updated in the database.
According to the [SQLAlchemy documentation](https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.JSON):
    The JSON type, when used with the SQLAlchemy ORM, does not detect in-place mutations to the structure.
    In order to detect these, the sqlalchemy.ext.mutable extension must be used, most typically using the MutableDict class.
    This extension will allow โ€œin-placeโ€ changes to the datastructure to produce events which will be detected by the unit of work.
    Alternatively, assigning a JSON structure to an ORM element that replaces the old one will always trigger a change event.
[flag_modified](https://docs.sqlalchemy.org/en/20/orm/session_api.html#sqlalchemy.orm.attributes.flag_modified)
[mutable](https://docs.sqlalchemy.org/en/20/orm/extensions/mutable.html)
@Harold2017
Harold2017 / install_cuda_12_ubuntu_22.04.md
Created October 3, 2025 03:02 — forked from ksopyla/install_cuda_12_ubuntu_22.04.md
How to install CUDA toolkit 12 on ubuntu 22.04, step by step guide

Step by step instruction how to install CUDA 12 Ubuntu 22.04

Clean all previous nvidia packages [optional step]

sudo apt purge nvidia*
sudo apt remove nvidia-*
sudo rm /etc/apt/sources.list.d/cuda*
@Harold2017
Harold2017 / windows_cpp_path_fix.md
Created July 8, 2025 02:43 — forked from mcwindy/windows_cpp_path_fix.md
Fix msvc & windows sdk environment variable in windows

This script is used to update MSVC and Windows SDK environment variables on Windows systems, simplifying the C++ configuration of Visual Studio Code.

It performs the following tasks:

  1. Check for Administrator Privileges: The script first checks if it is running with administrator privileges. If not, it prompts the user to run the script as an administrator and exits.

  2. Get Latest Version Path: It scans the specified base paths to find the latest version of MSVC and Windows SDK installations.

  3. Update Environment Variables:

@Harold2017
Harold2017 / vcpkg_install_qtwebengine.md
Last active February 6, 2025 01:41
vcpkg@bea476a80218a581bcb5318595849520217c825e install [email protected]

error with python 3.12

PS D:\vcpkg> ./vcpkg install qtwebengine:x64-windows --x-buildtrees-root=C:\tmp --no-print-usage
Computing installation plan...
The following packages will be built and installed:
    qtwebengine:x64-windows@6.8.1#1
Detecting compiler hash for triplet x64-windows...
@Harold2017
Harold2017 / make_vtk_camera.cpp
Created March 1, 2024 02:47 — forked from decrispell/make_vtk_camera.cpp
Convert standard camera intrinsic (focal length, principal point) and extrinsic parameters (rotation and translation) into a vtkCamera for rendering. Assume square pixels and 0 skew for now.
/**
* Convert standard camera intrinsic and extrinsic parameters to a vtkCamera instance for rendering
* Assume square pixels and 0 skew (for now).
*
* focal_len : camera focal length (units pixels)
* nx,ny : image dimensions in pixels
* principal_pt: camera principal point,
* i.e. the intersection of the principal ray with the image plane (units pixels)
* camera_rot, camera_trans : rotation, translation matrix mapping world points to camera coordinates
* depth_min, depth_max : needed to set the clipping range
@Harold2017
Harold2017 / pyw.md
Created October 3, 2023 03:50
run python script continuously in the background on windows
@Harold2017
Harold2017 / meber_visitor.cpp
Last active July 14, 2023 07:29
compile time aggregate type member visitor function (poor man's reflection in C++17)
//
// Created by Harold on 2023/7/14.
//
#include "member_visitor.h"
#include <cstdint>
#include <string>
#include <iostream>
@Harold2017
Harold2017 / divmod.md
Created October 15, 2022 10:27
c++ divmod operator undefined behavior
@Harold2017
Harold2017 / i18n.md
Created September 2, 2022 09:16
Avalonia I18N Setting

Add language resource to App.axml:

<Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceInclude Source="avares://MyAssembly/Assets/Languages/Lang.ENG.xaml"></ResourceInclude>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
</Application.Resources>
@Harold2017
Harold2017 / change_git_commit_email.sh
Created August 16, 2022 10:01
change git commit email
#!/bin/sh
git filter-branch -f --env-filter '
OLD_EMAIL="OLD EMAIL"
CORRECT_NAME="YOUR NAME"
CORRECT_EMAIL="YOUR EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]