Skip to content

Instantly share code, notes, and snippets.

[项目名称] - 当前功能规约

项目愿景:

文档状态:

  • 版本: [例如:1.0]

  • 最后更新: [例如:2025-09-20]

[Project Name] - Current Feature Specification

Project Vision:

Document Status:

  • Version: [e.g., 1.0]

  • Last Updated: [e.g., 2025-09-20]

@oylbin
oylbin / .gitattributes
Created April 21, 2025 09:28
.gitattributes example
###############################
# Git Line Endings #
###############################
# Set default behaviour to automatically normalize line endings.
* text=auto
# Force batch scripts to always use CRLF line endings so that if a repo is accessed
# in Windows via a file share from Linux, the scripts will work.
*.{cmd,[cC][mM][dD]} text eol=crlf
@oylbin
oylbin / text2speech.py
Created August 24, 2024 09:06
text to speech python script on macOS
import subprocess
from AppKit import NSSpeechSynthesizer
import time
def text_to_speech(sentence: str):
voice_identifier = "com.apple.voice.premium.zh-CN.Han"
synthesizer = NSSpeechSynthesizer.alloc().initWithVoice_(voice_identifier)
if synthesizer is None:
print(f"Error: Failed to initialize speech synthesizer with voice '{voice_identifier}'.")
@oylbin
oylbin / hexprint.c
Created March 12, 2024 12:59
hexdump or hexprint
void hexprint(void *buf, size_t s) {
unsigned char *byte = (unsigned char *)buf;
for (size_t i = 0; i < s; i++) {
if (i % 16 == 0 && i != 0) {
printf(" |");
for (size_t j = i - 16; j < i; j++) {
printf("%c", (byte[j] >= 32 && byte[j] <= 126) ? byte[j] : '.');
}
printf("|\n");
root = true
[*.{c,cc,cpp,cs,h,hpp,lua,py,js,ts,go}]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 120
@oylbin
oylbin / requestbin.py
Last active January 26, 2024 03:24
simple python http server like requestbin
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
# Get the size of data
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length).decode('utf-8')
from queue import Queue
import sys
import time
from PyQt6.QtCore import QSize, Qt, QObject, pyqtSlot, QThread, pyqtSignal
from PyQt6.QtGui import QTextCursor
from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QTextEdit, QVBoxLayout, QHBoxLayout, QWidget
class WriteStream(object):
@oylbin
oylbin / cmd.py
Created May 15, 2022 11:31
template for a python command line tool
#!/usr/bin/env python3
import os
import sys
import re
import pathlib
import logging
import click
import sh
@oylbin
oylbin / autohotkey.ahk
Created February 24, 2022 03:59
autohotkey配置
; 我同时使用MacOS和Windows工作,快捷键设置的主要目的是让两个系统的快捷键在键盘上的位置保持一致。
; 这样切换系统敲击键盘时,我不需要调整我的肌肉记忆。
; ! alt key(command key on macOS)
; # win key(option key on macOS)
; ^ ctrl key
; + shift key
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Enable warnings to assist with detecting common errors.