Skip to content

Instantly share code, notes, and snippets.

View mistivia's full-sized avatar

小葉薜荔 mistivia

View GitHub Profile
@mistivia
mistivia / tex2svg.sh
Last active January 24, 2026 03:21
Convert LaTeX formula to SVG
#!/bin/bash
# Usage: echo '$$E = mc^2$$' | tex2svg > einstein.svg
# 遇到错误立即退出
set -e
# 检查依赖工具
command -v xelatex >/dev/null 2>&1 || { echo >&2 "Error: xelatex not found."; exit 1; }
command -v pdf2svg >/dev/null 2>&1 || { echo >&2 "Error: pdf2svg not found."; exit 1; }
@mistivia
mistivia / .cwmrc
Created January 12, 2026 07:46
openbsd cwm config
sticky yes
gap 40 5 5 5
autogroup 0 "stalonetray"
unbind-key all
unbind-mouse all
bind-key CMS-q quit
bind-key CMS-r restart
@mistivia
mistivia / index.typ
Created January 8, 2026 11:11
Typst To HTML using SVG
// 标题
#import "/template.typ": doc-template
#doc-template(
title: "标题",
date: "2025-09-27",
body: [
= 章节
@mistivia
mistivia / simple-mailing-list.py
Last active December 3, 2025 13:27
Turn any imap/smtp email service into a mailing list
import imaplib
import smtplib
import time
import os
import email
from email.header import decode_header
from email.utils import parseaddr
from email.mime.text import MIMEText
from email.header import Header
import json
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) Daniel Stenberg, <[email protected]>, et al.
*
* This software is licensed as described in the file COPYING, which
@mistivia
mistivia / s3-uploader.py
Last active November 11, 2025 12:11
vibe-coded s3 upload gui
# pip install boto3 Pillow pyperclip
# --- 默认配置(可以为空,用户将在 GUI 中输入) ---
BUCKET = ''
REGION = ''
ACCESS_KEY = ''
SECRET_KEY = ''
ENDPOINT = ''
PREFIX = 'myuploads/'
VISIT_ENDPOINT = ''
@mistivia
mistivia / libevent_http_server.c
Created October 13, 2025 11:27
libevent http server
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <event2/event.h>
#include <event2/http.h>
#include <event2/buffer.h>
#include <event2/util.h>
#define SERVER_PORT 8080
@mistivia
mistivia / qemu-linux-host-windows10-guest.sh
Created October 11, 2025 19:17
windows 10 in qemu, with sound
qemu-system-x86_64 \
-machine q35,accel=kvm \
-enable-kvm \
-cpu host \
-smp 2 \
-m 4096 \
-drive id=mydrive0,if=none,file="./hdd.qcow2",format=qcow2 \
-device ide-hd,drive=mydrive0 \
-netdev user,id=mynet0 \
-device e1000-82545em,netdev=mynet0,mac=52:79:a0:d2:15:02 \
@mistivia
mistivia / borrow.hs
Last active May 31, 2025 19:23
Borrow like Rust in Linear Haskell
{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE LinearTypes #-}
{-# LANGUAGE QualifiedDo #-}
import Data.Type.Bool
import Foreign.Ptr (Ptr)
import Foreign.C.Types (CDouble)
import Foreign.Marshal.Alloc (free)
@mistivia
mistivia / monad.rkt
Last active May 15, 2025 14:13
Monad with do-notation in Racket
#lang racket
(define-syntax define-macro
(lambda (x)
(syntax-case x ()
((_ (macro . args) body ...)
#'(define-macro macro (lambda args body ...)))
((_ macro transformer)
#'(define-syntax macro
(lambda (y)