Skip to content

Instantly share code, notes, and snippets.

View Widowan's full-sized avatar
🌚

Widowan

🌚
View GitHub Profile
@Widowan
Widowan / BENCHMARK.md
Last active May 10, 2025 11:44
Benchmark of software overhead of Wireguard, Cloak, Xray, Hysteria and AmneziaWG

I benchmarked a few transport obfuscation protocols to use wireguard with. Here are the results.

Warning

The test is by no means scientific and should not be trusted blindly. You can see the very high loss rate, so it's more of a "software overhead" limit test.

Important

Again! This is not a proper becnhmark! To do proper benchmark, you'd need actual physical servers in same real 10/25 Gbit LAN which I can't afford for testing!

@Widowan
Widowan / 40-nekoray.rules
Created March 23, 2024 11:12
Polkit rules for activating nekoray VPN on linux without password prompt. Not very safe but suffice for personal machine.
// Drop in /etc/polkit-1/rules.d/ and restart `polkit` service.
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.policykit.exec" && subject.isInGroup("MYUSERNAME")) {
if (action.lookup("program") == '/usr/bin/pkill') {
return polkit.Result.YES;
}
if (action.lookup("command_line") == "/usr/bin/bash /home/MYUSERNAME/.config/nekoray/config/vpn-run-root.sh") {
return polkit.Result.YES;
}
@Widowan
Widowan / provision.sh
Last active January 22, 2024 14:45
Stupid simple SSH provisioning in Bash
#!/bin/bash
# Stupid simple SSH provisioning
# The idea is as follows:
#
# ./provision.sh
# ./actions/provision_ssl_certs.sh
# ./actions/provision_postgresql.sh
# ./actions/update_openssh.sh
# ./args/database_servers
#!/bin/bash
SINCE="$1"
UNTIL="$2"
SERVICES=(
pems@master-1
pems@master-2
pems@master-3
pems@worker-1
@Widowan
Widowan / exclude_nets.py
Last active August 27, 2023 07:26
Script to exclude multiple IPs/subnetworks from one starting network. Mainly was made for Wireguard with Cloak transport.
# python3 exclude_nets.py -s 0.0.0.0/0 -e 95.1.63.42/32,10.0.0.0/8,192.168.0.0/24
import ipaddress, getopt, sys, functools
def comparator(i1, i2):
if i1 == i2:
return 0
elif i1.overlaps(i2) and i1.num_addresses > i2.num_addresses:
return -1
else:
return 1
struct Sudoku {
data: Vec<Vec<u32>>,
}
impl Sudoku {
fn is_valid(&self) -> bool {
let size = self.data.len();
if (size as f32).sqrt() % 1.0 != 0.0 { return false }
@Widowan
Widowan / spring-boot-yandex-cloud.md
Last active February 25, 2023 14:31
Заметки по поводу запуска Spring Boot в Yandex Cloud Functions

Документация Yandex Cloud Functions (YCF) по части Java... очень скудная. За сим:

Во первых, в главе по Spring Boot написано, что YCF не поддерживает Spring Boot Loader - classloader, который Spring Boot использует по умолчанию и который предоставляется вместе со spring-boot-maven-plugin (из-за того что в YCF по видимому свой собственный classloader) (очевидно что его нужно убрать, а вместе с ним вы потеряете плюшки вроде mvn spring-boot:run).

Поэтому, нам, логично, необходимо от него избавится. Согласно документации, пропустить его можно используя, например, Maven Shade:

<plugin>
@Widowan
Widowan / spring-openapi-generator-404.md
Last active February 28, 2023 11:11
How to fix controller not working (404 error) with spring openapi-generator-maven-plugin

If you're getting 404 while trying to openapi-generator-maven-plugin, check if you're specifying correct package name (be it apiPackage, modelPackage or packageName).

It should either match with your main package (or any of its subpackages) name, or you have to use additional configuration to find @RestController bean.

i.e. if your main package is dev.wido.MyAmazingProject and you've specified following in plugin's config in pom.xml:

<apiPackage>dev.wido.openapi.api</apiPackage>

You have to add following configuration to your project:

@Widowan
Widowan / !visitor_enum.java
Last active February 20, 2023 14:16
Avoid switching on enum with visitor pattern
// Jdoodle link: https://jdoodle.com/ia/DH0
import java.util.function.BiFunction;
@SuppressWarnings("Convert2MethodRef")
enum Country {
// Can be `CHINA(CountryVisitor::visitChina)`, but that's A LOT less obvious IMO
CHINA((v, data) -> v.visitChina(data)),
INDIA((v, data) -> v.visitIndia(data));
// essentialy BiFunction<CountryVisitor<T, U>, T, U>,
@Widowan
Widowan / Zet comments
Last active November 23, 2024 16:27
(Some) comments left by Zet under Angel Beats OP, dumped from youtube API 16 June 2020. I think some chunks of the comments were lost :(
Day 1
Day 2 -I'll be doing this in jp time zone, not after 24 hours, let's see how long I can continue this pog
Day 3 hecin, almost forgot today
day 4, bout to head to slep, me ned some slep
Day 5
Day 6 Holy fucc I almost missed it
Day 7
Day 8... Still watching Overlord 2 for the 3rd time, might watch angel beas and Charlotte for memory lane, has been 6 months since I've watched those two.... I'm thinking of putting some thoughts/happening of the day from now on, sort of like a diary, might seem interesting.
Day 9 6 more minutes and I was ded holy fak
Day 10