Skip to content

Instantly share code, notes, and snippets.

View lilydjwg's full-sized avatar
🙃
dissappointed about the new UI and round avatars

依云 lilydjwg

🙃
dissappointed about the new UI and round avatars
View GitHub Profile
@lilydjwg
lilydjwg / ttc2ttf
Last active July 12, 2023 14:27
Convert .ttc to several .ttf files into the current directory
#!/usr/bin/env python3
import sys
import fontforge
def main(file):
for font in fontforge.fontsInFile(file):
f = fontforge.open(u'%s(%s)' % (file, font))
f.generate('%s.ttf' % font)
@lilydjwg
lilydjwg / libreap.c
Created February 14, 2014 12:34
make processes reap their own children processes
#include<stdio.h>
#include<sys/prctl.h>
__attribute__ ((constructor)) static void setup(void) {
if(prctl(PR_SET_CHILD_SUBREAPER, 1) != 0){
perror("prctl");
}
}
@lilydjwg
lilydjwg / lolcat.py
Last active February 4, 2020 12:24
lolcat.py: make rainbows over text
#!/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
@lilydjwg
lilydjwg / subreap.c
Created March 13, 2015 04:10
zsh/subreap module
#include<sys/prctl.h>
#include "subreap.mdh"
#include "subreap.pro"
/**/
static int
bin_subreap(char *nam, char **args, Options ops, UNUSED(int func))
{
int reaping = !OPT_ISSET(ops, 'u');
int result = prctl(PR_SET_CHILD_SUBREAPER, reaping);
@lilydjwg
lilydjwg / lxc-arch2
Last active April 9, 2024 16:34
lxc-arch2: a script to create a copy of my Arch Linux system in systemd-nspawn for testing
#!/bin/zsh -e
cd ~/tmpfs
mkdir -p .lxc-root .lxc-data/root/etc .lxc-work
sudo GDK_DPI_SCALE=$GDK_DPI_SCALE zsh -e - <<'EOF'
chown 0:0 .lxc-data/root .lxc-data/root/etc
modprobe overlay
mountpoint .lxc-root || mount -t overlay -o lowerdir=/,upperdir=$PWD/.lxc-data/root,workdir=$PWD/.lxc-root overlayfs $PWD/.lxc-root
#!/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 (
@lilydjwg
lilydjwg / cf-l-update
Created March 7, 2016 13:22
update your CloudFlare record when your IP changes
#!/usr/bin/env python3
import fcntl
import socket
import struct
import json
import urllib.request
from dns.resolver import Resolver
@lilydjwg
lilydjwg / dns-ipv6-reply
Created April 17, 2016 13:37
Answer AAAA DNS queries on behalf of a DNS server
#!/usr/bin/env python3
import socket
import struct
import traceback
import subprocess
import time
import signal
import dnslib
@lilydjwg
lilydjwg / .gitconfig
Created April 25, 2016 05:44
gitconfig (for older versions of git)
[color]
diff = auto
status = auto
branch = auto
grep = auto
showbranch = auto
[core]
excludesfile = ~/.gitconfig.d/gitignore
quotepath = false
[alias]
@lilydjwg
lilydjwg / colorpicker.c
Created April 25, 2016 09:48
a simple colorpicker in GTK
//=====================================================================
// 拾取颜色并输出
// 返回值:
// 0 正常
// 1 被取消
// 2 语法错
//---------------------------------------------------------------------
#include<gtk/gtk.h>
#include<ctype.h>
//---------------------------------------------------------------------