Skip to content

Instantly share code, notes, and snippets.

View WesleyCh3n's full-sized avatar
😺

WesleyCh3n WesleyCh3n

😺
View GitHub Profile
@WesleyCh3n
WesleyCh3n / opencv_yolov7_tflite.cpp
Last active September 13, 2022 09:43
Tensorflow Lite (tflite) using cv::Mat as input (Tiny Yolo v7) - C++ / Python
#include "opencv2/opencv.hpp"
#include "tensorflow/lite/interpreter.h"
#include "tensorflow/lite/kernels/register.h"
#include "tensorflow/lite/model.h"
#include "tensorflow/lite/optional_debug_tools.h"
#include <iostream>
int main(int argc, char *argv[]) {
// initailize tflite model
const char *filename = "./best.tflite";
@WesleyCh3n
WesleyCh3n / install.ps1
Last active May 16, 2022 04:23
Analyze install script
Write-Host @'
Downloading fuan analyze...
'@
$root_dir = "fuan.analyze"
if (Test-Path $root_dir) {
Remove-Item $root_dir -Force -Recurse
}
@WesleyCh3n
WesleyCh3n / invert_mouse_wheel.ps1
Created February 22, 2022 02:46
Windows 10 mouse wheel direction
# open powershell in administrator mode
$mode = Read-host "How do you like your mouse scroll (0 or 1)?"; Get-PnpDevice -Class Mouse -PresentOnly -Status OK | ForEach-Object { "$($_.Name): $($_.DeviceID)"; Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters" -Name FlipFlopWheel -Value $mode; "+--- Value of FlipFlopWheel is set to " + (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Enum\$($_.DeviceID)\Device Parameters").FlipFlopWheel + "`n" }
# 0: default direction
# 1: invert direction
# Reboot to take effect
@WesleyCh3n
WesleyCh3n / arm64-cross.Dockerfile
Last active September 12, 2021 15:07
Dockerfile of arm64/armv7 for rpi cross-compile base on `dockross`. Toolchain: https://sourceforge.net/projects/raspberry-pi-cross-compilers/files/
FROM dockcross/base:latest
ENV DEFAULT_DOCKCROSS_IMAGE arm64-cross
ENV CROSS_TRIPLE aarch64-linux-gnu
ENV XCC_PREFIX /usr/local
ENV CROSS_ROOT ${XCC_PREFIX}/${CROSS_TRIPLE}
ENV AS=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-as \
AR=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc-ar \
CC=${CROSS_ROOT}/bin/${CROSS_TRIPLE}-gcc \

Electron is tricky to get set up on Windows Subsystem for Linux, but it can work!

Four things needed overall:

  1. you need WSL2, not WSL1
  2. you need node, of course, and that part isn't so bad
  3. you need to apt install several dependencies
  4. you need an X Server so it can display the electron GUI over in Windows-land

Setup instructions, in order:

@softwarebygabe
softwarebygabe / options_functional_async.ts
Last active January 12, 2023 02:45
How to write an async class constructor using functional options pattern
type Material = 'wood' | 'brick' | 'steel'
type HouseOption = (h: House) => void
class House {
private rooms: number
private floors: number
private material: Material
private externalData: any
@PurpleBooth
PurpleBooth / README.md
Last active September 8, 2023 20:52
A github workflow pipeline for rust that does test, build and deploy windows, linux and mac, creates releases, and does SemVer Versioning, and releases to a homebrew tap

Features

  • Automatically bump SemVer
  • Update a personal homebrew tap
  • Keep that pesky version in the Cargo.toml up to date
  • (From dependabot) Get new versions out as soon as possible

Assumptions

  • You don't want a changelog
@maboloshi
maboloshi / README.md
Last active May 1, 2024 03:10
[Mac下配置Aria2] #macOS #aria2

Mac下配置Aria2

安装和设置 Aria2

# 使用 Homebrew 安装 aria2
brew install aria2

# 创建配置文件aria2.conf和空对话文件aria2.session
mkdir ~/.aria2 && cd ~/.aria2
touch aria2.conf
@pburtchaell
pburtchaell / TapEventOverrides.tsx
Last active August 24, 2022 08:38
Double tap & long press event overrides for Framer X
import { Data, Override } from "framer"
const state = Data({
doubleTapIndex: 0,
doubleTapTimer: setTimeout(null, null),
longPress: false,
longPressTimer: setTimeout(null, null),
})
export function doubleTap(): Override {
@YashasSamaga
YashasSamaga / yolov4.py
Last active February 18, 2024 04:03
YOLOv4 on OpenCV DNN
import cv2
import time
CONFIDENCE_THRESHOLD = 0.2
NMS_THRESHOLD = 0.4
COLORS = [(0, 255, 255), (255, 255, 0), (0, 255, 0), (255, 0, 0)]
class_names = []
with open("classes.txt", "r") as f:
class_names = [cname.strip() for cname in f.readlines()]