Skip to content

Instantly share code, notes, and snippets.

View lich4's full-sized avatar
💭
I may be slow to respond.

lich4 lich4

💭
I may be slow to respond.
  • Baidu.Inc
  • China Shanxi XIAN
View GitHub Profile
@lich4
lich4 / build_procursus_macos.sh
Last active May 21, 2026 03:57
Build Procursus on MacOS
#!/bin/bash
git clone https://github.com/ProcursusTeam/Procursus
mkdir -p /opt/procursus/bin
brew install gmake
ln -s /usr/local/bin/gmake /opt/procursus/bin/make
brew install bash
ln -s /usr/local/bin/bash /opt/procursus/bin/bash
curl -fLss "https://raw.githubusercontent.com/julian-klode/triehash/master/triehash.pl" -o /opt/procursus/bin/triehash
@lich4
lich4 / CVPixelBufferUtils.mm
Last active January 1, 2025 05:04
CVPixelBuffer crop/scale/rotate
typedef struct CM_BRIDGED_TYPE(id) VTImageRotationSession* VTImageRotationSessionRef;
typedef struct CM_BRIDGED_TYPE(id) VTPixelTransferSession* VTPixelTransferSessionRef;
extern "C" {
OSStatus VTImageRotationSessionCreate(CFAllocatorRef, uint32_t, VTImageRotationSessionRef*);
OSStatus VTImageRotationSessionSetProperty(VTImageRotationSessionRef, CFStringRef, CFTypeRef);
OSStatus VTImageRotationSessionSetProperties(VTImageRotationSessionRef, CFDictionaryRef);
OSStatus VTImageRotationSessionTransferImage(VTImageRotationSessionRef, CVPixelBufferRef, CVPixelBufferRef);
OSStatus VTImageRotationSessionTransferSubImage(VTImageRotationSessionRef, CVPixelBufferRef, CVPixelBufferRef);
OSStatus VTPixelTransferSessionCreate(CFAllocatorRef, VTPixelTransferSessionRef*);
OSStatus VTPixelTransferSessionSetProperty(VTPixelTransferSessionRef, CFStringRef, CFTypeRef);
@lich4
lich4 / build_openssl_ios.sh
Last active July 27, 2024 14:53
build ios openssl
#!/bin/bash
IOS_MIN_SDK_VERSION="12.0"
IOS_SDK_VERSION=""
VERSION="1.1.1" # OpenSSL version default
CORES=8
OPENSSL_VERSION="openssl-${VERSION}"
DEVELOPER=`xcode-select -print-path`
PLATFORM="iPhoneOS"
SYSROOT="${DEVELOPER}/Platforms/$PLATFORM.platform/Developer/SDKs/${PLATFORM}${IOS_SDK_VERSION}.sdk"
@lich4
lich4 / flat_json.js
Created June 22, 2024 15:35
Flatten json object to 1 layer object
function flat(obj, prefix, is_arr) {
if (!prefix) {
prefix = "";
is_arr = false;
var tobj = Object.prototype.toString.call(obj);
if (tobj == "[object Array]") {
is_arr = true;
}
}
return Object.keys(obj).reduce(function(memo, prop) {