Skip to content

Instantly share code, notes, and snippets.

View Harold2017's full-sized avatar
😃

Harold Harold2017

😃
View GitHub Profile
@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 / go_cpu.md
Created June 25, 2019 04:48
golang cpu usage in docker

Golang CPU usage in docker

// test.go
package main

import (
	"fmt"
@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 / github_actions_golang.md
Created September 16, 2019 09:56
github actions golang, build, test, codecov

build

name: build
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
@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 / buildInfo.md
Created November 1, 2019 10:14
add build info to go binary
package version

// reference: https://stackoverflow.com/questions/11354518/application-auto-build-versioning

import (
	"fmt"
	"runtime"
	"strings"
)
@Harold2017
Harold2017 / divmod.md
Created October 15, 2022 10:27
c++ divmod operator undefined behavior
@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" ]
// ------------------------------------------------------------------------
// Benchmark LGCG Time LTO Time Iterations LTCG Build LTO Build
// ------------------------------------------------------------------------
// regex_boost 317 ns 69.1 ns 2133333 00:02.720 00:08.70
// regex_ctre 248 ns 4.79 ns 2800000 05:08.755 00:04.78
// regex_hyperscan 96.7 ns n/a 7466667 00:52.487 n/a
// regex_re2 186 ns 3.97 ns 4072727 00:03.353 00:05.94
// regex_spirit 44.3 ns 0.644 ns 15448276 00:03.487 00:05.25
// regex_std 2371 ns 67.2 ns 280000 00:02.442 00:05.54
// regex_xpressive 552 ns 273 ns 1000000 00:05.369 00:11.52