Skip to content

Instantly share code, notes, and snippets.

依云 lilydjwg

Block or report user

Report or block lilydjwg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lilydjwg / gh-check
Created Aug 16, 2019
gh-check: speed test to known GitHub IPs
View gh-check
import asyncio
import time
import socket
import sys
import aiohttp
class MyConnector(aiohttp.TCPConnector):
lilydjwg / findorphanfiles
Created Aug 3, 2019
Find files not managed by pacman (for Arch Linux and derivatives)
View findorphanfiles
import os
def allrepofiles():
repo = '/var/lib/pacman/local'
files = set()
for dirpath, dirnames, filenames in os.walk(repo):
for file in filenames:
if file != 'files':
View btrfs-autosnapshot
import os
import datetime
import subprocess
import logging
import tempfile
import contextlib
import ctypes
from pathlib import Path
lilydjwg / show-mem-usage
Last active Jul 20, 2019
show-mem-usage: parse /proc/{pid}/maps and show how much memory is used by each file/type
View show-mem-usage
'''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)
lilydjwg /
Created Nov 13, 2018
mosh3: a mosh helper that reuses ssh connections (ControlMaster)
#!/usr/bin/env python3
# inspired by
import sys
import os
import subprocess
def main():
lilydjwg /
Last active Jun 16, 2019
cleanup HaoZip file extension registration
# 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)
lilydjwg / git-ls-large
Created Dec 31, 2017
git-ls-large: find large objects in your git repo
View git-ls-large
#!/bin/bash -e
if [[ $# -gt 1 ]]; then
objects=$(git verify-pack -v "${idx[@]}" | grep -v -e 'non delta' -e 'chain length' -e '.git/objects' | sort -k3nr | head)
lilydjwg / readonlyroot
Created May 15, 2017
readonlyroot: make / readonly but permit writes to some paths
View readonlyroot
#!/bin/bash -e
if [[ $EUID -ne 0 ]]; then
echo >&2 "Need to be root."
exit 1
if ! mountpoint /mnt >/dev/null; then
exit 2
lilydjwg / zfs-show
Created Jan 1, 2017
zfs-show: a wrapper to `zfs get` to show values from multiple properties in a table nicely
View zfs-show
#!/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()]
lilydjwg / mynetns_run
Created May 13, 2016
mynetns_run: Run a program in a seperate network namespace
View mynetns_run
#!/bin/bash -e
if [[ ! -f $NETNS_FILE ]]; then
ip netns add mynet
ip link add mynet0 type veth peer name mynet1
ip link set mynet0 up
You can’t perform that action at this time.