Skip to content

Instantly share code, notes, and snippets.

dissappointed about the new UI and round avatars

依云 lilydjwg

dissappointed about the new UI and round avatars
View GitHub Profile
lilydjwg / device-powersave
Created January 26, 2023 09:43
device-powersave: turn on powersave mode for devices except USB HID ones
View device-powersave
import os
import glob
def main():
patterns = [
lilydjwg / pacsync
Created October 29, 2020 14:21
pacsync: sync with latest mirrors, download from fastest ones
View pacsync
#!/bin/bash -e
unshare -m bash <<'EOF'
mount --make-rprivate /
for f in /etc/pacman.d/*.sync; do
mount --bind "$f" "$filename"
pacman -Sy
lilydjwg /
Last active March 15, 2023 20:06 show all kinds of terminal colors at a glance
from functools import partial
def colors16():
for bold in [0, 1]:
for i in range(30, 38):
for j in range(40, 48):
print(f'\x1b[{bold};{i};{j}m {bold};{i};{j} |\x1b[0m', end='')
lilydjwg / use-cpu.c
Last active May 10, 2020 12:53
use-cpu: nothing but uses up one cpu core, printing out how much cpu time allocated to it every second
View use-cpu.c
volatile uint64_t count = 0;
void alarm_handler() {
lilydjwg / zhist.c
Created February 23, 2020 11:23
A simple C program to decode & encode zsh history file
View zhist.c
// 让 zsh 的历史记录可读
void readhist();
void writehist();
void usage();
lilydjwg / gh-check
Last active February 10, 2023 07:27
gh-check: speed test to known GitHub IPs
View gh-check
import asyncio
import time
import socket
import argparse
import aiohttp
class MyConnector(aiohttp.TCPConnector):
lilydjwg / findorphanfiles
Created August 3, 2019 07:43
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':
lilydjwg / btrfs-autosnapshot
Last active February 25, 2023 12:13
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 July 20, 2019 07:47
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 November 13, 2018 07:11
mosh3: a mosh helper that reuses ssh connections (ControlMaster)
#!/usr/bin/env python3
# inspired by
import sys
import os
import subprocess
def main():