Skip to content

Instantly share code, notes, and snippets.


ipid ipid

  • Beijing University of Posts and Communications
  • Beijing, China
  • Twitter @ipid__
View GitHub Profile
ipid / swas.wg0.server.conf
Created Aug 19, 2022
Wireguard DMZ 示例,一条命令让你轻松拥有公网地址。An example of Wireguard DMZ configuration that provides you a public IPv4 address.
View swas.wg0.server.conf
Address =
PrivateKey = ******************************************
ListenPort = 51000
PostUp = iptables -t nat -F; iptables -t nat -A PREROUTING -p tcp -m multiport --dports 1024:50999,51001:65534 -i eth0 -j DNAT --to-destination; iptables -t nat -A PREROUTING -p udp -m multiport --dports 1024:50999,51001:65534 -i eth0 -j DNAT --to-destination; iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE
PostDown = iptables -t nat -F
AllowedIPs =
ipid / B站视频显示点赞率.user.js
Created Jan 23, 2022
用于在 B 站视频播放页显示点赞率、收藏率、P 名的用户脚本。
View B站视频显示点赞率.user.js
// ==UserScript==
// @name B站视频显示点赞率
// @namespace
// @version 0.1
// @description 在视频播放页面显示点赞率(点赞数 / 总播放数)
// @author ipid
// @match *://*
// ==/UserScript==
(function () {
ipid /
Created Dec 17, 2021
Convert between PIL Image and Numpy while using torchvision
import numpy as np
from PIL import Image
__all__ = (
IMAGE_MEAN = np.array([0.485, 0.456, 0.406], dtype=np.float32).reshape((3, 1, 1))
IMAGE_STD = np.array([0.229, 0.224, 0.225], dtype=np.float32).reshape((3, 1, 1))
ipid /
Last active May 10, 2021
Python Quine 中文版
# Python 自打印程序示例
# 直接运行本程序,控制台就会输出这个程序本身的代码!
打印内容 = '''# Python 自打印程序示例
# 直接运行本程序,控制台就会输出这个程序本身的代码!
print_content = {引号}{引号}{引号}{替换内容}{引号}{引号}{引号}
print(打印内容.format(引号="'", 替换内容=打印内容))'''
ipid /
Last active Apr 3, 2020
Print class methods and fields info through reflection, as if you were reading source code.
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
* Usage:
* <code>
* System.out.print(printInfo(java.time.format.DateTimeFormatter.class));
ipid /
Last active Jan 15, 2020
Simple warning light flashing in your terminal. Written in C++17 with ncurses.
Simple warning light flashing in your terminal.
Compile with the following arguments:
<YOUR COMPILER> --std=c++17 -O2 -lcurses -o warn-light
#include <ncurses.h>
#include <stdint.h>
#include <unistd.h>
ipid / heap_var.hpp
Last active May 30, 2019
Define variables on the heap but use them like stack variables. Heap variables have never been so simple to use.
View heap_var.hpp
#pragma once
#ifndef HEAP_VAR_HPP
#define HEAP_VAR_HPP
In order not to cause a stack overflow, sometimes you must define
large objects on the heap. But heap variables are somewhat hard to use.
ipid / print_type_name.hpp
Last active Apr 8, 2019
Functions to print name of a type, with std::cout. Work under C++14.
View print_type_name.hpp
#pragma once
void print_type_name<T>() {...}
Print type name of T, exactly the same as declaration.
ipid / defer.hpp
Created Mar 25, 2019
Simple Scope-guard(defer) implementation under C++17.
View defer.hpp
#pragma once
defer.hpp v20190325
Simple Scope-guard(defer) implementation under C++17.
Released under MIT License.
Support: C++17