Skip to content

Instantly share code, notes, and snippets.

View hsupu's full-sized avatar
🌏
Inside

Hsu Pu hsupu

🌏
Inside
View GitHub Profile
// library
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-template-friend"
template<typename Tag, typename Tag::type MemberPointer>
struct Rob {
friend decltype(MemberPointer) access(Tag) { return MemberPointer; }
};
@hsupu
hsupu / JacksonHelper.java
Last active November 24, 2020 16:45
Java Jackson Usage Example.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.util.TokenBuffer;
@hsupu
hsupu / sysctl.conf
Created June 7, 2020 04:03
For Proxy/Forward Server.
# BBR
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
fs.file-max = 1000000
fs.inotify.max_user_instances = 8192
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_tw_reuse = 1
@hsupu
hsupu / adcalc.c
Created May 27, 2020 13:48
公元日期计算
#include <stdio.h>
#include <stdlib.h>
int days_m[] = {
31,
28,
31,
30,
31,
30,
@hsupu
hsupu / anti-csdn-ad.js
Created February 20, 2020 14:31
尝试屏蔽 CSDN 博文的广告与导流
// ==UserScript==
// @name anti-csdn-ad-checker
// @namespace http://tampermonkey.net/
// @version 0.1
// @description csdn sucks!
// @author noname
// @match https://blog.csdn.net/*/article/details/*
// @grant none
// @requires https://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
@hsupu
hsupu / forward-windows-smb.md
Last active December 22, 2019 06:21
向本地网络之外开放 Windows SMB

使用 netsh 做端口转发

netsh interface portproxy delete v6tov4 listenaddress=any listenport=23139
netsh interface portproxy delete v6tov4 listenaddress=any listenport=23445

netsh interface portproxy add v6tov4 listenaddress=[::] listenport=23139 connectaddress=127.0.0.1 connectport=139
netsh interface portproxy add v6tov4 listenaddress=[::] listenport=23445 connectaddress=127.0.0.1 connectport=445
@hsupu
hsupu / netplan-example.yaml
Created December 17, 2019 08:09
A netplan example config for Ubuntu 18.04
network:
version: 2
renderer: networkd
ethernets:
ens192:
dhcp4: yes
dhcp6: yes
optional: yes
ens37:
dhcp4: no
@hsupu
hsupu / port-forwarder-between-4-and-6.md
Last active December 15, 2019 16:06
不同 IP 协议间的端口转发

所用工具:

  • Linux MacOS 使用 socat,需要从包管理器安装;
  • Windows 使用系统自带的 netsh;

4to6

使用 SOCAT

server-ip=
server-port=25565
use-native-transport=true
# 传输压缩的下限,超过此值会尝试压缩(-1 表示禁用)
network-compression-threshold=1460
max-players=8
# 是否进行正版用户名验证
online-mode=false
# 正版验证时是否接受来源 IP 不一致的情况
@hsupu
hsupu / deploy-terraria-server-zh.md
Last active December 2, 2019 07:27
中文的 Terraria Server 部署指南

本文参考自 https://terraria.gamepedia.com/Server

1)下载服务器程序

截至发布时,最新版本为 1.3.5.3。你也可以在参考网址里下载到最新版。

下载到的压缩包内有 Windows Linux Mac 三个子目录,分别是三个平台对应的版本。本文以 Linux 版本为例。