This file contains 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
#include<stdio.h> | |
#include<sys/prctl.h> | |
__attribute__ ((constructor)) static void setup(void) { | |
if(prctl(PR_SET_CHILD_SUBREAPER, 1) != 0){ | |
perror("prctl"); | |
} | |
} |
This file contains 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 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 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 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 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 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 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 os | |
import sys | |
from urllib.parse import parse_qs | |
import subprocess | |
import json | |
from PyQt5 import QtWebKit, QtWebKitWidgets | |
from PyQt5.QtCore import ( |
This file contains 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 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/busyloop/lolcat | |
import sys | |
import re | |
import os | |
from math import ceil | |
from colorsys import hsv_to_rgb | |
from unicodedata import east_asian_width |
OlderNewer