Skip to content

Instantly share code, notes, and snippets.

View ZiYueCommentary's full-sized avatar

子悦解说 ZiYueCommentary

View GitHub Profile
@ZiYueCommentary
ZiYueCommentary / tw.js
Created April 10, 2025 14:28
A simple Javascript library for converting between Traditional and Simplified Chinese. Powered by OpenCC.
// 我承认这么做很不好,但够用就行
document.write("<a href=\"javascript:void(0);\" onclick=\"tranToSimp();\" target=\"_self\">简体中文</a> | <a href=\"javascript:void(0);\" onclick=\"simpToTran();\" target=\"_self\">繁体中文</a>");
const s2t = OpenCC.Converter({ from: 'cn', to: 'twp' });
const t2s = OpenCC.Converter({ from: 'twp', to: 'cn' });
if(getCookie("trans_conv") == "true") simpToTran();
async function simpToTran() {
document.cookie = "trans_conv=true; domain=.scpcbgame.cn; path=/; expires=Fri, 31 Dec 9999 23:59:59 GMT";
@ZiYueCommentary
ZiYueCommentary / events.bb
Created February 7, 2024 03:46
An event system in BlitzBasic. Requires FastPointer.
Dim Events%(10)
Global i% = 0
Function RegistryEvent(ptr%)
Events(i) = ptr
i = i + 1
End Function
Function EventHelloworld%(msg%)
Print "Hello World!"
@ZiYueCommentary
ZiYueCommentary / worker.js
Created October 6, 2023 12:05
An out-of-the-box Github Mirror for Cloudflare Workers.
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request));
})
async function fetchAndApply(request) {
let url = new URL(request.url);
url.protocol = 'https:';
let new_request_headers = new Headers(request.headers);
new_request_headers.set('Host', url.hostname);
@ZiYueCommentary
ZiYueCommentary / PhoneDetector.js
Last active December 27, 2022 08:38
A simple way to detect whether user using phone to visit website.
var system = {};
var p = navigator.platform;
system.win = p.indexOf("Win") == 0;
system.mac = p.indexOf("Mac") == 0;
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
if(!(system.win||system.mac||system.xll)) {
alert("something to shown up when user is using phone.");
}
@ZiYueCommentary
ZiYueCommentary / cc.cpp
Last active January 19, 2023 02:06
Counting characters that existing in the file. UTF-8 only.
/*
* Character Counter - Made by ZiYueCommentary
* Counting characters that existing in the file, Require C++20.
*
* v1.2 2023/1/19
*
* Download Executable: https://files.ziyuesinicization.site/cc.exe
*/
#include <fstream>