Skip to content

Instantly share code, notes, and snippets.

View TransparentLC's full-sized avatar
🐟
Touching fish _(:зゝ∠)_

✨小透明・宸✨ TransparentLC

🐟
Touching fish _(:зゝ∠)_
View GitHub Profile
@TransparentLC
TransparentLC / base85.js
Created May 7, 2021 10:16
Base85 编码和解码
const charset = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~';
const charsetReverse = charset
.split('')
.reduce((acc, cur, idx) => {
acc[cur] = idx;
return acc;
}, {});
/**
* @param {Uint8Array} data
@TransparentLC
TransparentLC / perm.js
Last active April 26, 2021 01:23
生成置换和原地求逆置换
const generatePerm = (len, rng) => {
const result = new Array(len);
for (let i = 0; i < len; i++) {
result[i] = i;
}
for (let i = len - 1; i >= 0; i--) {
const j = rng() % (i + 1);
[result[i], result[j]] = [result[j], result[i]];
}
return result;
@TransparentLC
TransparentLC / xoshiro128ss.py
Created March 12, 2021 16:26
可播种的随机数生成器 xoshiro128**。如果只是为了生成随机 uint32 整数的话,Python 自带的 random.randint、random.randbytes 和 os.urandom 比它都快上不少。
import ctypes
class Xoshiro128ss:
def __init__(self, a: int, b: int, c: int, d: int):
self.s = tuple(ctypes.c_uint32(x) for x in (a, b, c, d))
self.t = ctypes.c_uint32()
self.r = ctypes.c_uint32()
def randInt(self) -> int:
s0, s1, s2, s3 = self.s
@TransparentLC
TransparentLC / dummy-file.py
Last active March 22, 2021 15:56
使用多进程生成随机数据填充的文件。
import argparse
import multiprocessing
import re
import os
import sys
import time
def parseFileSize(string: str) -> int:
try:
size, unit = re.search(r'^([0-9]*\.?[0-9]+)((?:b|kb|mb|gb)?)$', (string if type(string) is str else str(string)).lower()).groups()
@TransparentLC
TransparentLC / icas-login.py
Last active December 27, 2020 07:26
ICAS模拟登录,可以用于对 https://jwxk.jnu.edu.cn/ 等各种使用 ICAS 进行统一登录的系统的自动化操作。
import getpass
import pydes
import re
import requests
username = input('Username: ')
password = getpass.getpass('Password: ')
session = requests.Session()
response = session.get('https://icas.jnu.edu.cn/cas/login')
@TransparentLC
TransparentLC / phar-builder.php
Created December 10, 2020 03:25
并没有什么用的 PHAR 打包脚本
<?php
/*
PHAR打包脚本
使用方法:
php phar-builder.php /path/to/build/config.json
打包配置文件:
{
// 项目名称,也是打包的文件名称
@TransparentLC
TransparentLC / xoshiro128ss.js
Created October 23, 2020 07:29
可播种的随机数生成器 xoshiro128**
/**
* Random number generator "xoshiro128**".
* @see http://prng.di.unimi.it/xoshiro128starstar.c
*/
class Xoshiro128ss {
/**
* Init the RNG with given seed.
* The default seed is taken from current timestamp.
* @param {Number} [a]
* @param {Number} [b]
@TransparentLC
TransparentLC / lazyload.example.html
Last active August 4, 2020 13:54
部分参考 https://github.com/tuupola/lazyload 的图片懒加载插件,添加了自动选择 AVIF 和 WebP 格式的支持,本质上是在造轮子 2333
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/gh/w3c/IntersectionObserver/polyfill/intersection-observer.min.js"></script>
@TransparentLC
TransparentLC / qsticker.py
Last active March 8, 2024 23:07
下载手机 QQ 的原创表情,使用方式:qsticker.py --emoticonid 203291 --destination /any/dir --zip
import argparse
import json
import os
import re
import requests
import requests.exceptions
import threading
import zipfile
from requests.models import Response
#!/usr/bin/env pwsh
# https://stackoverflow.com/questions/8761888/capturing-standard-out-and-error-with-start-process
function Start-Command ([String]$Path, [String]$Arguments) {
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $Path
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.Arguments = $Arguments