Skip to content

Instantly share code, notes, and snippets.

@msoxzw
msoxzw / server.py
Created April 21, 2022 19:58
QUIC server
import argparse
import asyncio
import struct
import aioquic.asyncio
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.events import StreamDataReceived
_I = struct.Struct('!I')
@msoxzw
msoxzw / client.py
Created April 21, 2022 19:57
QUIC client
import argparse
import asyncio
import ssl
import struct
import aioquic.asyncio
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.events import StreamDataReceived
_I = struct.Struct('!I')
@msoxzw
msoxzw / quic.py
Created April 20, 2022 20:41
QUIC benchmark
import argparse
import asyncio
import ssl
import struct
import aioquic.asyncio
from aioquic.quic.configuration import QuicConfiguration
from aioquic.quic.events import StreamDataReceived
_I = struct.Struct('!I')
@msoxzw
msoxzw / udp.py
Created April 12, 2022 23:10
asycnio udp benchmark
import argparse
import asyncio
import struct
_I = struct.Struct('!I')
class UDPClient(asyncio.DatagramProtocol):
def __init__(self, size, time):
@msoxzw
msoxzw / Add Tracking Protection Lists.ps1
Created August 6, 2021 09:18
Add Internet Explorer Tracking Protection Lists from known Adblock Plus subscriptions and by language
Push-Location $PSScriptRoot
$subscriptionsURL = 'https://raw.githubusercontent.com/adblockplus/adblockpluscore/master/data/subscriptions.json'
$subscriptions = Invoke-WebRequest $subscriptionsURL | ConvertFrom-Json
$language = (Get-UICulture).TwoLetterISOLanguageName
if ($language -notin $subscriptions.languages) {$language = 'en'}
$registryPath = 'HKCU:\Software\Microsoft\Internet Explorer\Safety\PrivacIE\Lists'
$added = Get-ItemPropertyValue "$registryPath\*" 'Name'
@msoxzw
msoxzw / Calculator.py
Last active September 14, 2020 14:59
Infinite-precision calculator
import code
from argparse import ArgumentParser
from decimal import getcontext
from functools import update_wrapper
from sys import float_info
from tokenize import generate_tokens, untokenize, NUMBER, STRING, NAME, OP
operations = [
f'__{a}{b}__' for a in ['', 'r', 'i']
for b in ['add', 'sub', 'mul', 'matmul', 'truediv',
@msoxzw
msoxzw / setup.cmd
Created December 13, 2019 10:40
One click to generate all one click JetBrains products installer
@echo off
if "%~1" == "" (
set products=https://data.services.jetbrains.com/products?fields=code,name,distributions
PowerShell "(Invoke-WebRequest $env:products | ConvertFrom-Json).Where{$_.distributions.windows}.ForEach{Set-Content ('%~dp0' + $_.name + '.cmd') ('@\"%%~dp0setup.cmd\" ' + $_.code)}"
exit /b
)
if not exist "%~3" aria2c -d %Temp% --on-download-complete "%~dp0setup.cmd" "https://data.services.jetbrains.com/products/download?code=%1&platform=windows" & exit /b
@msoxzw
msoxzw / Internet Explorer Tracking Protection Lists.html
Created December 13, 2019 08:15
Internet Explorer Tracking Protection Lists dynamically generated by Adblock Plus subscriptions with multiple languages choices given by wikimeida
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Internet Explorer Tracking Protection Lists</title>
<style>
body {
font-family: Segoe UI, sans-serif, Segoe UI Emoji;
}
@msoxzw
msoxzw / toUTF8.py
Last active December 13, 2019 08:06
automatcially convert any character encoding to UTF-8, line ending to '\n'
import glob
import sys
from concurrent.futures import ProcessPoolExecutor
from itertools import chain
from cchardet import UniversalDetector
detector = UniversalDetector()
@msoxzw
msoxzw / run.cmd
Last active September 14, 2020 14:57
One command line run as self-elevated administrator
@whoami /groups | find "S-1-16-8192" && (echo Start-Process cmd '/c ""%~f0" %*"' -Verb RunAs | PowerShell - & exit /b)