Skip to content

Instantly share code, notes, and snippets.

View 0x1306a94's full-sized avatar
😶
depressed

0x1306a94 0x1306a94

😶
depressed
View GitHub Profile
@0x1306a94
0x1306a94 / build_ios.py
Created September 21, 2023 08:12
mars build xcframework
#!/usr/bin/env python
import os
import sys
import glob
from mars_utils import *
SCRIPT_PATH = os.path.split(os.path.realpath(__file__))[0]
@0x1306a94
0x1306a94 / swift_macro_not_use_spm.md
Last active March 28, 2024 12:35
Swift Macro does not use SPM integration

Swift Macro 不使用 Swift Package Manager如何集成

  • Swift Macro分为两部分,一部分为宏的具体实现(编译器插件),一部分为Macro Lib用于导出宏定义以及所需要的附属代码,这里说的不使用SPM指的是编译器插件这部分
  • 仔细观察Xcode使用SPM集成Macro时,在编译命令中通过-load-plugin-executable参数指定了对应宏实现的插件可执行文件路径
  • 同时在swift源码中也找到了相关参数TypeCheckMacros.cpp TypeCheckMacros.cpp
  • swift源码中可得知,宏实现插件即可以是动态库(dylib)也可以是可执行文件
  • 系统内置的宏实现是通过 -plugin-path <dylib path> 加载
  • 内置的宏实现动态库在Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/Lib/swift/host/plugins
具体步骤
  • 编写宏实现代码,这一步可以通过SPM也可以直接通过Xcode创建命令行程序项目,完成宏实现代码编写
@0x1306a94
0x1306a94 / simd_macos_def.h
Last active June 5, 2023 12:30
TenniS SIMD
// source https://github.com/TenniS-Open/TenniS/blob/ef6c8332809a021d0eb5842c0f9d32a7f0b07f96/include/kernels/common/simd_def/simd_base_def.h
#ifndef TENSORSTACK_KERNELS_COMMON_SIMD_DEF_SIMD_MACOS_DEF_H
#define TENSORSTACK_KERNELS_COMMON_SIMD_DEF_SIMD_MACOS_DEF_H
#ifdef TS_USE_MACOS_SIMD
#include <simd/vector.h>
typedef struct _simd_f32x4x3 {
simd_float4 val[3];
} _simd_f32x4x3;
//
// main.cpp
// FaceFeaturesCompare
//
// Created by king on 2023/5/13.
//
#include <chrono>
#include <ctime>
#include <iostream>
use core::slice;
use std::alloc::{alloc, dealloc, Layout};
use std::cmp::min;
const DEFAULT_UNIT_SIZE: usize = 128;
#[derive(Debug)]
pub enum Seek {
Start,
Cur,
@0x1306a94
0x1306a94 / base64_cxx_tmp.cc
Created February 18, 2023 00:16 — forked from unixzii/base64_cxx_tmp.cc
A Base64 implementation using C++ template metaprogramming.
template<auto... Val>
struct List;
template<>
struct List<> {
template<auto Elem>
using Append = List<Elem>;
};
template<auto Head, auto... _Rest>
import Foundation
class Throttle {
private let queue: DispatchQueue
private let delay: Double
private var delayedBlock: (() -> Void)?
private var cancelBlock: (() -> Void)?
private var timer: DispatchSourceTimer?
private var isReady = true
private var hasDelayedBlock: Bool { delayedBlock != nil }
@0x1306a94
0x1306a94 / skip_translate.js
Last active March 1, 2024 14:23
让谷歌翻译插件翻译网页的时候,绕过代码块和一些无需翻译的元素
// ==UserScript==
// @name 谷歌翻译绕过代码块(适配github,mathworks等)
// @version 0.2
// @description 让谷歌翻译插件翻译网页的时候,绕过代码块和一些无需翻译的元素
// @match http*://*/*
// @match localhost:*
// @match 127.0.0.1:*
// @match *
// @license MIT
// @grant none
@0x1306a94
0x1306a94 / libpng_test.c
Created August 25, 2022 10:01 — forked from niw/libpng_test.c
How to read and write PNG file using libpng. Covers trivial method calls like png_set_filler.
/*
* A simple libpng example program
* http://zarb.org/~gc/html/libpng.html
*
* Modified by Yoshimasa Niwa to make it much simpler
* and support all defined color_type.
*
* To build, use the next instruction on OS X.
* $ brew install libpng
* $ clang -lz -lpng16 libpng_test.c
@0x1306a94
0x1306a94 / pthread_test.c
Last active July 24, 2022 03:11
pthread test
//
// main.c
// testdadkajdkajf
//
// Created by king on 2022/7/22.
//
#include <pthread.h>
#include <setjmp.h>
#include <stdio.h>