Skip to content

Instantly share code, notes, and snippets.

View wzyboy's full-sized avatar

Zhuoyun Wei wzyboy

View GitHub Profile
@wzyboy
wzyboy / Better Usage.md
Created August 11, 2017 01:41 — forked from jordansissel/Better Usage.md
Strip package scripts from .deb packages (postinst, postrm, preinst, prerm)

The best way to use this tool is to hook apt's use of dpkg to run it before doing any package installs.

In your apt.conf, put this:

DPkg::Pre-Install-Pkgs {"xargs -rL1 bash /path/to/stripdeb.sh 2>&1 | logger -t stripdeb"}

Then, a demo:

% sudo apt-get install mysql-server-5.1

@wzyboy
wzyboy / mfm.py
Last active April 28, 2017 21:02
mpv fc-match: A quick and dirty way to determine whether you have all the fonts required in an ass file
#!/usr/bin/env python
import os
import argparse
import subprocess
def get_fonts_from_ass_file(ass_file):
try:
with open(ass_file) as f:
#!/usr/bin/env python
import os
import sys
from zlib import crc32
def crc(filename):
MAX_FILE_SIZE = 1024 * 1024 * 1024 * 2 # 2 GiB
if os.path.getsize(filename) > MAX_FILE_SIZE:
@wzyboy
wzyboy / xor.py
Last active April 22, 2017 11:53
XOR
#!/usr/bin/env python3
import os
import numpy
from zlib import crc32
from shutil import copy
from argparse import ArgumentParser
def xor(data, key):
@wzyboy
wzyboy / name.py
Last active November 24, 2015 05:41
#!/usr/bin/env python3
import sys
import unicodedata
from argparse import ArgumentParser
print('Unicode data version: {}'.format(unicodedata.unidata_version))
def name(chars):
# Maintainer: Zhuoyun Wei <wzyboy@wzyboy.org>
pkgname=ocserv
pkgver=0.10.9
pkgrel=1
pkgdesc="OpenConnect VPN Server"
arch=('i686' 'x86_64')
url="http://www.infradead.org/ocserv/"
license=('GPL2')
depends=('gnutls')
@wzyboy
wzyboy / ocroute.sh
Last active October 3, 2015 16:06
ocroute
#!/bin/bash -
# Description: A simple script handling default routing for OpenConnect
# URL: https://gist.github.com/wzyboy/07d80b51ff2f8bc50a7c
# Author: Zhuoyun Wei <wzyboy@wzyboy.org>
# Optional: Scripts for chnroutes
# https://github.com/jimmyxu/chnroutes
VPNUP="/etc/openvpn/vpn-up.sh"
VPNDOWN="/etc/openvpn/vpn-down.sh"
@wzyboy
wzyboy / import.py
Last active August 29, 2015 14:16
A script that helps to import Twitter's official archive.
#!/usr/bin/env python
USAGE = """
This script helps to import Twitter's official archive.
Usage: ./import.py tweets.csv
"""
"""
Original data structure:
@wzyboy
wzyboy / ttf-ms-win8-japanese.conf
Created July 27, 2014 03:45
ttf-ms-win8 fontconfig
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<matchtarget="font"><testname="family"><string>MS Gothic</string></test><editname="embeddedbitmap"><bool>false</bool></edit></match>
<matchtarget="font"><testname="family"><string>MS UI Gothic</string></test><editname="embeddedbitmap"><bool>false</bool></edit></match>
<matchtarget="font"><testname="family"><string>MS PGothic</string></test><editname="embeddedbitmap"><bool>false</bool></edit></match>
<matchtarget="font"><testname="family"><string>MS Mincho</string></test><editname="embeddedbitmap"><bool>false</bool></edit></match>
<matchtarget="font"><testname="family"><string>MS PMincho</string></test><editname="embeddedbitmap"><bool>false</bool></edit></match>
</fontconfig>
@wzyboy
wzyboy / foursquare.bash
Last active August 29, 2015 13:56
Simple Foursquare Bash utility.
#!/bin/bash -
# Author: Zhuoyun Wei <wzyboy@wzyboy.org>
# Usage: 1. Get your token.
# 2. Fill in / replace information below.
# 3. Source this file.
# 4. `newvenue "某某地铁站 Foobar Metro Station" 120.1234,31.5678`
# to add a new venue. Note the order of lat and long.
# 5. `addlist VENUEID` to add a venue to your (existing) list.