Skip to content

Instantly share code, notes, and snippets.

View leiless's full-sized avatar
🎯
Focusing

Fishbone° leiless

🎯
Focusing
  • Shanghai, China
  • 04:11 (UTC +08:00)
View GitHub Profile
@leiless
leiless / kuaidi100.diff
Created September 2, 2024 08:21
快递100官方 vs 快递100赝品: 中通快递 78830479593611
diff --git a/1 b/2
index f1ecb34..d38606a 100644
--- a/1
+++ b/2
@@ -1,194 +1,66 @@
{
"message": "ok",
- "nu": "78830479593611",
- "ischeck": "1",
+ "no": "78830479593611",
#!/usr/bin/perl
use strict;
use warnings;
use autodie;
my $mirrors = 'https://mirrors.tuna.tsinghua.edu.cn/centos-stream';
if (@ARGV < 1) {
die "Usage: $0 <filename1> <filename2> ...\n";
@leiless
leiless / sshpass-1.09-1.10.diff
Last active July 1, 2024 03:33
sshpass main.c diff 1.09 vs 1.10
diff --git a/sshpass-1.09/main.c b/sshpass-1.10/main.c
index 8a75d61..2bad28b 100644
--- a/sshpass-1.09/main.c
+++ b/sshpass-1.10/main.c
@@ -29,6 +29,7 @@
#include <sys/ioctl.h>
#include <sys/select.h>
+#include <assert.h>
#include <unistd.h>
@leiless
leiless / restore-etc-resolv-conf-on-wsl-2.md
Last active May 30, 2024 07:38
How to restore default `/etc/resolv.conf` on WSL 2
@leiless
leiless / ms-edge-tts-api.md
Created May 10, 2024 06:05 — forked from wilinz/ms-edge-tts-api.md
微软edge-tts-api(大声朗读协议)
import os
import sys
import zipfile
import shutil
def unzip_py_env(py_env_zip: str):
py_env_dir = py_env_zip.removesuffix('.zip')
need_update = not os.path.isdir(py_env_dir)
if not need_update:
@leiless
leiless / _setmode.rs
Last active April 10, 2024 06:48
Rust windows: Set stdin(fd=0) translation mode to binary mode.
#[cfg(target_os = "windows")]
extern {
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode?view=msvc-170
// https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-6.0/aa298581(v=vs.60)
fn _setmode(fd: std::os::raw::c_int, mode: std::os::raw::c_int) -> std::os::raw::c_int;
// https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/wwfcfxas(v=vs.100)
fn _get_errno(p_value: *mut std::os::raw::c_int) -> std::os::raw::c_int;
}
#[cfg(target_os = "windows")]
@leiless
leiless / aes256_gcm_cbc_pkcs7.rs
Created April 3, 2024 03:27
Rust: AES-256, CBC mode, PKCS#7 padding
use aes::cipher::block_padding::Pkcs7;
use aes::cipher::{KeyIvInit, BlockEncryptMut, BlockDecryptMut};
use rand::RngCore;
type Aes256CbcEnc = cbc::Encryptor<aes::Aes256>;
type Aes256CbcDec = cbc::Decryptor<aes::Aes256>;
const AES256_SECRET_SIZE: usize = 32;
const AES256_BLOCK_SIZE: usize = 16;
@leiless
leiless / aes_256_cbc_pkcs7.py
Created April 3, 2024 02:18
Python: AES-256, CBC mode, PKCS#7 padding
#!/usr/bin/env python3
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives import padding
# https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/
# https://cryptography.io/en/latest/hazmat/primitives/padding/#cryptography.hazmat.primitives.padding.PKCS7
class AES256:
KEY_SIZE = 32
BLOCK_SIZE = 16
@leiless
leiless / pushd-popd.py
Last active February 22, 2024 06:18
Bring bash's pushd/popd to Python3
#!/usr/bin/env python3
import os
import sys
DIR_STACK = []
def pushd(path: str):