This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
'''parse /proc/{pid}/smaps and show how much RSS memory is used by each file/type''' | |
import sys | |
from collections import defaultdict | |
def filesize(size: int) -> str: | |
units = 'KMGTPEZY' | |
left = abs(size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# inspired by | |
# https://github.com/mobile-shell/mosh/issues/24#issuecomment-201893250 | |
import sys | |
import os | |
import subprocess | |
def main(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: admin privileges is necessary | |
import winreg | |
i = 0 | |
while True: | |
key = winreg.EnumKey(winreg.HKEY_CLASSES_ROOT, i) | |
value = winreg.QueryValue(winreg.HKEY_CLASSES_ROOT, key) | |
if value.startswith('HaoZip.'): | |
print(f'Deleting {key} ({value})...', end='', flush=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [[ $# -gt 1 ]]; then | |
idx=($@) | |
else | |
idx=(.git/objects/pack/pack-*.idx) | |
fi | |
objects=$(git verify-pack -v "${idx[@]}" | grep -v -e 'non delta' -e 'chain length' -e '.git/objects' | sort -k3nr | head) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
if [[ $EUID -ne 0 ]]; then | |
echo >&2 "Need to be root." | |
exit 1 | |
fi | |
if ! mountpoint /mnt >/dev/null; then | |
exit 2 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import subprocess | |
from collections import namedtuple, OrderedDict | |
Record = namedtuple('Record', 'name property value source') | |
def get_widths(item): | |
return [len(x) for x in item.values()] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
NETNS_FILE=/var/run/netns/mynet | |
MNTNS_FILE=/var/run/ns/mynet_mnt | |
if [[ ! -f $NETNS_FILE ]]; then | |
ip netns add mynet | |
ip link add mynet0 type veth peer name mynet1 | |
ip link set mynet0 up |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//===================================================================== | |
// 拾取颜色并输出 | |
// 返回值: | |
// 0 正常 | |
// 1 被取消 | |
// 2 语法错 | |
//--------------------------------------------------------------------- | |
#include<gtk/gtk.h> | |
#include<ctype.h> | |
//--------------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
grep = auto | |
showbranch = auto | |
[core] | |
excludesfile = ~/.gitconfig.d/gitignore | |
quotepath = false | |
[alias] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import socket | |
import struct | |
import traceback | |
import subprocess | |
import time | |
import signal | |
import dnslib |