Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
import serial
with serial.Serial("/dev/ttyUSB0", 9600, timeout=0.05) as ser:
buf = [0xc0, 0x00, 0x08,
0x03, 0xea, 0x84, 0x00, 0x0f, 0x03, 0x00, 0x00]
ser.write(bytes(buf))
r = ser.read(11)
print(r)
buf = [0xc1, 0x00, 0x08]
ser.write(bytes(buf))
import Flow
-- could replace following Just to pure (keep the first one?)
-- infix bind, boring!
-- https://www.youtube.com/watch?v=ZhuHCtR3xq8
-- \a -> f a >>= \a -> g a
-- where f :: a -> M b
-- g :: b -> M c
-- when the type a = b = c
-- it could be seem as Monoid?
#include <iostream>
#include <string>
namespace utils {
size_t sprintHex(char *out, size_t outSize, const uint8_t *bytes, size_t size) {
size_t i = 0;
// 2 hex chars + 1 null terminator
if (outSize < (size * 2 + 1)) {
return 0;
}
#Mod_Priority,#Mod_Status,#Mod_Name
"0001","+","Creation Club: ccvsvsse004-beafarmer"
"0002","+","Creation Club: ccvsvsse003-necroarts"
"0003","+","Creation Club: ccvsvsse002-pets"
"0004","+","Creation Club: ccvsvsse001-winter"
"0005","+","Creation Club: cctwbsse001-puzzledungeon"
"0006","+","Creation Club: ccrmssse001-necrohouse"
"0007","+","Creation Club: ccqdrsse002-firewood"
"0008","+","Creation Club: ccpewsse002-armsofchaos"
"0009","+","Creation Club: ccmtysse002-ve"
@crosstyan
crosstyan / libdrm2-dummy.txt
Last active September 14, 2023 16:34
libdrm2-dummy
### Commented entries have reasonable defaults.
### Uncomment to edit them.
# Source: <source package name; defaults to package name>
Section: misc
Priority: optional
# Homepage: <enter URL here; no default>
Standards-Version: 1.0
Package: libdrm2-dummy
# Version: <enter version here; defaults to 1.0>
# Update in 2023/06/19
# 1. frp no longer provide systemctl service file. This script creates frpc/fprs systemctl service file by itself
# 2. Update frp from 0.33.0 to 0.49.0
# 3. User=nobody is no longer suggested, use DynamicUser=yes instead
wget https://github.com/fatedier/frp/releases/download/v0.49.0/frp_0.49.0_linux_amd64.tar.gz --directory-prefix=/tmp
DIR=frp_0.49.0_linux_amd64
tar -zxvf /tmp/$DIR.tar.gz -C /tmp
@crosstyan
crosstyan / length.cpp
Last active July 26, 2023 07:21
basically a variant of std::duration. C++20 is required since concept is used.
#include <cstddef>
#include <cstdint>
#include<format>
#include<chrono>
#include<concepts>
#include <ratio>
#include <type_traits>
#include<utility>
#include<iostream>
@crosstyan
crosstyan / arduino-esp-idf-5.1.md
Last active July 19, 2023 03:32
Use Arudino with ESP IDF 5.1

Use Arudino with ESP IDF 5.1

Install ESP IDF

git clone https://github.com/espressif/esp-idf -b v5.1 --depth=1 --recursive
cd esp-idf
./install.sh
source export.sh

Bandwith test with eGPU (thunderbolt 3)

$ nvidia-smi
Thu Jun  8 23:49:42 2023       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 530.41.03              Driver Version: 530.41.03    CUDA Version: 12.1     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                  Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf            Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
# use the real gcc instead of the apple clang
# brew install gcc
export CC=gcc-13
export CXX=g++-13
# brew uninstall binutils
# Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+
# brew install gmp mpfr libmpc
JOBS=6
# generate with
# chage the jobs to the number of your cpu cores