Skip to content

Instantly share code, notes, and snippets.

@zhangjun
zhangjun / image_preprocess.cc
Created July 7, 2021 07:41
image_preprocess.cc
#include <vector>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
namespace ImageUtils {
// imagenet preprocessing function
cv::Mat preprocess_image(cv::Mat image) {
cv::Mat float_image;
image.convertTo(float_image, CV_32FC3);
@zhangjun
zhangjun / check_fma.cc
Created September 3, 2021 11:06
cpu fma check
#include <iostream>
#ifdef _WIN32
// For __cpuid
#include <intrin.h>
#endif
#define uint32_t unsigned int
struct CPUID {
@zhangjun
zhangjun / gpu_compiler.m
Created December 9, 2021 03:13 — forked from marysaka/gpu_compiler.m
Simple program to compile a given Metal file into a device specific dynamic Metal library (GPU code)
// clang gpu_compiler.m -fobjc-arc -fmodules -mmacosx-version-min=11.0 -framework Foundation -framework CoreGraphics -o gpu_compiler
#import <Foundation/Foundation.h>
#import <Metal/Metal.h>
void compile_to_gpu_code(id<MTLDevice> device, NSString *programString, NSString *destinationPath) {
NSError *error;
MTLCompileOptions *options = [MTLCompileOptions new];
options.libraryType = MTLLibraryTypeDynamic;
options.installName = [NSString stringWithFormat:@"@executable_path/userCreatedDylib.metallib"];
@zhangjun
zhangjun / how-to-install-latest-gcc-on-ubuntu-lts.txt
Created December 19, 2021 03:53 — forked from application2000/how-to-install-latest-gcc-on-ubuntu-lts.txt
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
@zhangjun
zhangjun / py2_SimpleHTTPServerWithUpload.py
Created June 2, 2022 07:27 — forked from sparkydogX/py2_SimpleHTTPServerWithUpload.py
在SimpleHTTPServer中加入上传功能
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.2"
__all__ = ["SimpleHTTPRequestHandler"]
@zhangjun
zhangjun / best.md
Created February 21, 2024 03:40 — forked from AshtakaOOf/best.md
Best Anime SD Models SDv1/SDXL

My current favorite SD models

Warning

To access the discord post links please join the TouhouAI (24k members) discord server.

WIP

from dataclasses import dataclass
import threading, signal
import queue
import time
@dataclass
class JobTask:
is_even: bool = False
idx: int = 0
tm: int = 0
/*自定义样式,实时生效*/
/* 全局属性
* 页边距 padding: 30px;
* 全文字体 font-family: ptima-Regular;
* 英文换行 word-break: break-all;
*/
#nice {
font-size: 14px;
letter-spacing: 0.05em;