Skip to content

Instantly share code, notes, and snippets.

View crosstyan's full-sized avatar

Crosstyan crosstyan

View GitHub Profile
@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))
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;
}