Skip to content

Instantly share code, notes, and snippets.

@wkgcass
wkgcass / worker.js
Created April 13, 2024 03:04
Use Cloudflare Workers to proxy git requests to Github
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
let url = request.url
if (url.indexOf("://") !== -1) {
url = url.substring(url.indexOf("://") + "://".length)
}
if (url.indexOf("/") !== -1) {
@wkgcass
wkgcass / musl-aarch64.Dockerfile
Last active December 4, 2023 17:18
Dockerfile for GraalVM Native Image (can build static native-images)
FROM ubuntu:20.04
RUN apt update
RUN apt install -y wget ca-certificates build-essential zlib1g zlib1g-dev locales
# configure locales first
RUN locale-gen zh_CN
RUN locale-gen zh_CN.utf8
ENV LANG zh_CN.UTF-8
@wkgcass
wkgcass / Bad00Main.java
Created October 21, 2023 16:44
JDK 21 String Template Bug
import java.util.function.*;
class JDBC {
void transaction(Consumer<ConnectionW> f) {
f.accept(new ConnectionW());
}
<T> T transaction(Function<ConnectionW, T> f) {
return f.apply(new ConnectionW());
}
}
@wkgcass
wkgcass / Main.java
Last active September 24, 2023 21:50
test mmap rss
public class Main {
public static void main(String[] args) {
var arr = new byte[(1024 * 1024)][];
new Thread(() -> {
while (true) {
var total = Runtime.getRuntime().totalMemory();
System.out.println(total);
try {
Thread.sleep(5 * 1000);
} catch (Exception ignore) {
@wkgcass
wkgcass / setgrayscale.js
Last active December 4, 2022 21:21
油猴脚本-把灰色网页变回彩色
// ==UserScript==
// @name setgrayscale
// @version 0.1
// @description x
// @author wkgcass
// @match *://*/*
// ==/UserScript==
(function() {
'use strict';
@wkgcass
wkgcass / Main.java
Created July 20, 2022 08:57
list-window-info
import com.sun.jna.Native;
import com.sun.jna.Structure;
import com.sun.jna.win32.StdCallLibrary;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Main {
@wkgcass
wkgcass / change-volume.ps1
Created July 19, 2022 08:36
change-colume.ps1
$def = @"
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
namespace SetAppVolume
{
public class AppMuter
{
public static void Mute(string app)
@wkgcass
wkgcass / X.java
Last active May 24, 2022 03:40
AntiXXN.java
import javax.net.ssl.SSLParameters;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;
public class X {
@wkgcass
wkgcass / TimeElemImpl.java
Last active January 10, 2021 12:07
TimeWheel example (TODO)
package vproxybase.util.time.timewheel;
import vproxybase.util.LogType;
import vproxybase.util.Logger;
import vproxybase.util.time.TimeElem;
public class TimeElemImpl<T> implements TimeElem<T> {
final long timeoutTs;
private final T value;
@wkgcass
wkgcass / test.c
Created January 6, 2021 13:11
lsqpack demo
#include <stdio.h>
#include <stdlib.h>
#include "lsqpack.h"
#include "lsxpack_header.h"
void dhi_unblocked(void* hblock_ctx) {
printf("dhi_unblocked\n");
}
typedef struct st_hblock_ctx {