Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
@crosstyan
crosstyan / check_bitfield_order.cpp
Last active August 21, 2024 17:01
check bitfield order of struct
#include <cstdint>
#include <cstdio>
enum class StructBitfieldOrder {
/// the most significant bit as the first appearing field in a struct
MSB_AS_FIRST_FIELD,
/// the least significant bit as the first appearing field in a struct
LSB_AS_FIRST_FIELD,
/// should not happen
OTHER,
@crosstyan
crosstyan / proxy.ps1
Created July 23, 2024 18:11
set proxy environment variable
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted
$proxy_host = "http://192.168.5.2"
$proxy_port = 36000
$before_path = Get-Location
function remove-env($name) {
$before= Get-Location
try {
# https://stackoverflow.com/questions/8388650/powershell-how-can-i-stop-errors-from-being-displayed-in-a-script
Set-Location Env:
@crosstyan
crosstyan / cv.py
Last active June 12, 2024 19:28
a stupid anyio with multiprocess
import random
import time
from multiprocessing import cpu_count
from typing import (
Any,
Awaitable,
Callable,
Final,
Generic,
Iterable,
@crosstyan
crosstyan / counter.m
Last active May 24, 2024 07:43
a demo of closure with Matlab (R2023b)
% https://www.mathworks.com/matlabcentral/answers/439671-why-i-cannot-define-a-function-in-live-script
[inc, get] = createCounter();
inc();
inc();
disp(get());
% https://www.mathworks.com/help/matlab/function-handles.html
obj = createCounterMap();
disp(obj);
@crosstyan
crosstyan / rsync-rootfs.md
Created April 8, 2024 04:46 — forked from kalaksi/rsync-rootfs.md
Copy the whole root filesystem excluding pseudo-filesystems and mountpoints

Copying the whole linux root filesystem locally or remotely using rsync

Explanation of chosen options:

  • Verbose output with speed and progress information
  • Try to preserve all possible information: file attrs, hardlinks, ACLs and extended attrs,
  • Exclude contents of pseudo-filesystems and mountpoints
  • In this example source host is remote and destination local.
rsync --info=progress2  -vaHAX --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} source.host:/ /local/destination
@crosstyan
crosstyan / example.ipynb
Last active March 13, 2024 03:55
an example to parse NOAA hurricanes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@crosstyan
crosstyan / webrtc_for_work.rst
Created January 10, 2024 15:57 — forked from voluntas/webrtc_for_work.rst
仕事で WebRTC

仕事で WebRTC

日時:2023-01-15
作:@voluntas
バージョン:2023.1
url:https://voluntas.github.io/

この資料は以下の製品の宣伝を含みます。

@crosstyan
crosstyan / cpp.std.coroutines.draft.md
Created December 26, 2023 17:36 — forked from MattPD/cpp.std.coroutines.draft.md
C++ links: Coroutines (WIP draft)
import math
import click
def emphasize(word: str, strength: float) -> tuple[str, float]:
"""
The weight of AI focus will be multiplied by 1.05 if you enclose the tags or
text you want the AI to focus on more with { and }
e.g.
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))