Skip to content

Instantly share code, notes, and snippets.

View SoTosorrow's full-sized avatar
🧻
Dreaming

Cuimi SoTosorrow

🧻
Dreaming
View GitHub Profile
@SoTosorrow
SoTosorrow / tmp2023-12-31
Created December 31, 2023 06:54
For Wsl docker
* at https://github.com/microsoft/WSL/discussions/4872
> touch /etc/fstab
> update-alternatives --set iptables /usr/sbin/iptables-legacy
> update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
> service docker start
@SoTosorrow
SoTosorrow / ocr.py
Created January 19, 2023 03:15
OCR Screenshot Notify
from PIL import Image, ImageGrab
from plyer import notification
import time
import numpy as np
import pytesseract
import easyocr
import keyboard
class TesseractOcr:
def __init__(self):
@SoTosorrow
SoTosorrow / file_seek.rs
Created January 11, 2023 04:31
Rust File'question about seek/buf
fn main() {
let mut file = File::options().read(true).write(true).open("json.txt").unwrap();
let mut file_reader = BufReader::new(file); // Rust文件读写是无缓冲的, 使用BufReader/BufWriter为文件读写增加缓冲
let mut result = String::new();
let mut result2 = String::new();
// Rust 文件操作会改变seek位置,且多个clone共享。当某个clone read_to_string后,此时file已经到EOF,其他clone再读也是空。必须重置seek
// let seek = file.seek(std::io::SeekFrom::Current(0)).unwrap();
// file.try_clone().unwrap().read_to_string(&mut result).unwrap();
// file.seek(std::io::SeekFrom::Start(seek)).unwrap();
@SoTosorrow
SoTosorrow / piano_frequencies_list.js
Created December 7, 2022 02:28
piano_frequencies
let piano_frequencys = [
27.500, 29.135, 30.868, 32.703, 34.648, 36.708, 38.891, 41.203,
43.654, 46.249, 48.999, 51.913, 55.000, 58.270, 61.735, 65.406,
69.296, 73.416, 77.782, 82.407, 87.307, 92.499, 97.999, 103.826,
110.000, 116.541, 123.471, 130.813, 138.591, 146.832, 155.563, 164.814,
174.614, 184.997, 195.998, 207.652, 220.000, 233.082, 246.942, 261.626,
277.183, 293.665, 311.127, 329.628, 349.228, 369.994, 391.995, 415.305,
440.000, 466.164, 493.883, 523.251, 554.365, 587.330, 622.254, 659.255,
698.456, 739.989, 783.991, 830.609, 880.000, 932.328, 987.767, 1046.502,
1108.731, 1174.659, 1244.508, 1318.510, 1396.913, 1479.978, 1567.982, 1661.219,
@SoTosorrow
SoTosorrow / test.rs
Last active October 17, 2022 06:48
coroutine and async in tokio
tokio::runtime::Builder::new_multi_thread().worker_threads(4).enable_all().build().unwrap().block_on(
async{
let mut handles = Vec::with_capacity(8);
for i in 1..4{
let joinhandle = tokio::spawn(async move{
tokio::task::yield_now().await;
co_run(i).await;
});
handles.push(joinhandle);
风雪渐披肩,入夜阑火蜷