Skip to content

Instantly share code, notes, and snippets.

View comzyh's full-sized avatar
🏢
Thinking about Ops

Comzyh comzyh

🏢
Thinking about Ops
View GitHub Profile
@comzyh
comzyh / remove_unused_veth.ps1
Created September 22, 2020 14:30
Powershell Remove unused Hyper-V vEthernet Adapter
$Devs = (Get-NetAdapter | Where-Object -Property Name -Like vEthernet* | Where-Object -Property Status -Like "Not Present" )
ForEach ($Dev in $Devs) {
$RemoveKey = "HKLM:\SYSTEM\Setup\Upgrade\NetworkDriverBackup\Control\Network\{4d36e972-e325-11ce-bfc1-08002be10318}\$($Dev.InstanceId)"
Remove-Item -Path $RemoveKey
}
@comzyh
comzyh / clash_stress.go
Last active December 18, 2019 09:43
Stress tester for clash tun
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"log"
"net"
"sync"
@comzyh
comzyh / breed_enter_linux.py
Last active May 2, 2022 12:14
a Python version of Breed Enter which can be used under linux
#!/usr/bin/env python3
import socket
import time
import threading
import signal
import sys
import os
sending = None
@comzyh
comzyh / water-netstack-echo.go
Last active June 18, 2020 05:51
Demo intergate songgao/water with google/netstack for Tun
package main
import (
"fmt"
"log"
"os"
"strings"
"github.com/google/netstack/tcpip"
"github.com/google/netstack/tcpip/adapters/gonet"
@comzyh
comzyh / zigzag.cpp
Created April 22, 2019 04:38
zigzag
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
void zigzag(int m, int n) {
vector<vector<int> > ground(m);
for (size_t i = 0; i < m; i++) {
ground[i].resize(n);
}
@comzyh
comzyh / rand_k_in_n.cpp
Created March 28, 2019 07:58
rand_k_in_n.cpp
#include <algorithm>
#include <random>
#include <iostream>
#include <vector>
using namespace std;
vector<int> random_k_in_n(size_t k, int n) { // generate k distinct number in [0..n-1]
vector<int> ans;
ans.reserve(k);
std::random_device rd;
@comzyh
comzyh / partial_random_shuffle.cpp
Created March 28, 2019 05:42
partial_random_shuffle.cpp
#include <algorithm>
#include <random>
#include <iostream>
using namespace std;
template< class RandomIt>
void partial_random_shuffle( RandomIt first, RandomIt last, RandomIt part) {
typename std::iterator_traits<RandomIt>::difference_type i, n, p;
p = part - first;
n = last - first;
@comzyh
comzyh / bold_max.py
Created February 25, 2019 13:32
[Latex] Highlight maximum value in line
import re
import sys
def main():
for line in sys.stdin.readlines():
line = re.sub(r'\\textbf\{(?P<value>(\d+)?\.\d+)\}', lambda g: g.group('value'), line)
maxval = 0.0
for v in re.finditer(r'(?P<value>(\d+)?\.\d+)', line):
maxval = max(maxval, float(v.group('value')))
def rep_func(group):
# print(float(group.group('value')) == maxval)
@comzyh
comzyh / ubuntu.json
Created November 22, 2018 07:04
Ubuntu theme colors for tilix
{
"name": "Ubuntu",
"comment": "Ubuntu default/theme terminal colors for tilix",
"use-theme-colors": false,
"foreground-color": "#ffffff",
"background-color": "#300a24",
"palette": [
"#2e3436",
"#cc0000",
"#4e9a06",
@comzyh
comzyh / addbom.py
Created December 27, 2017 06:35
Add BOM to .h file
import os
import os.path
import sys
import codecs
def main():
print(sys.argv[1])
for root, dirs, files in os.walk(sys.argv[1]):
for file in files:
if file.endswith('.h'):