Skip to content

Instantly share code, notes, and snippets.

View hghwng's full-sized avatar

Hugh Wang hghwng

  • Beijing, China
  • 11:37 (UTC +08:00)
View GitHub Profile
@hghwng
hghwng / pdf2pptx
Created August 29, 2019 07:03
Converts PDF to PowerPoint. Fonts embedded.
#!/bin/bash -e
vectorize() {
input="$(realpath "$1")"
output="$(realpath "$2")"
mkdir -p _vectorize
cd _vectorize
echo "1. pdf to pages"
@hghwng
hghwng / decrypt.py
Created March 25, 2019 02:52
Decrypt TrainerRoad Course
#!/usr/bin/env python
def decode_buf(ciphertext):
from Crypto.Protocol.KDF import PBKDF2
(KEY_SIZE, IV_SIZE) = (256 // 8, 128 // 8)
key_iv = PBKDF2("4ZpHznL4ELiAiZEXpAloFPA7sO4NqVLLd8qavZ8D", b"vxZIH70vLr9i8pymHC0U", dkLen=KEY_SIZE + IV_SIZE)
(key, iv) = (key_iv[:KEY_SIZE], key_iv[KEY_SIZE:])
from Crypto.Cipher import AES
@hghwng
hghwng / PKGBUILD
Last active September 29, 2018 02:37
NuSMV for Arch Linux
# Maintainer: Alex Szczuczko <[email protected]>
# Contributor: Marcelo Alaniz <[email protected]> Hugh Wang <[email protected]>
pkgname=nusmv
_pkgname=NuSMV
pkgver=2.6.0
pkgrel=2
pkgdesc="A new symbolic model checker"
arch=('i686' 'x86_64')
url="http://nusmv.fbk.eu/index.html"
@hghwng
hghwng / replay.cc
Created January 21, 2018 13:48
Run LLVM Fuzzer Without Dependencies
#include <cassert>
#include <iostream>
#include <fstream>
#include <vector>
#define ATTR_WEAK __attribute__((weak))
extern "C" {
int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
@hghwng
hghwng / .gitignore
Last active October 16, 2024 11:28
SciTools Understand for Arch Linux
pkg/
src/
understand-bin-*.pkg.*
Understand-*.tgz
.SRCINFO
@hghwng
hghwng / backlight
Last active September 4, 2017 15:01
Backlight profile switcher
#!/bin/bash
# Screen brightness and color temperature
function set-brightness-i2c() {
sudo ddcutil -l "$1" setvcp 0x10 "$2" &
}
function set-brightness-builtin() {
xbacklight -set "$1" -time 0
@hghwng
hghwng / build
Created September 2, 2017 01:35
CBR mp3 quality ABX test with squishyball
#!/bin/sh
set -u
function towav {
ffmpeg -i "$1" -f wav "raw.wav"
}
function conv() {
fullname="$1"
bitrate="$2"
@hghwng
hghwng / mail
Created July 23, 2017 10:22
中文邮件的 yasnippet 模板
# -*- mode: snippet -*-
#name : mail
#key : mail
#author : Hugh Wang
# --
${1:尊敬的 XXX}
您好。
$0
@hghwng
hghwng / parse-week.el
Created September 6, 2016 03:07
Org mode: parse week with customizable start of week number
(with-eval-after-load 'org
(setq start-week 37)
(advice-add 'org-read-date-analyze :around
(lambda (original-fun ans org-def org-defdecode)
(funcall original-fun
(if (string-match "^s\\([0-9]+\\)\\(.*\\)" ans)
(concat "w"
(number-to-string (+ start-week
(string-to-number (match-string 1 ans))))
(match-string 2 ans))
@hghwng
hghwng / opmlconv.py
Created August 7, 2016 12:21
Convert Dynalist flavored OPML to Org Mode
#!/usr/bin/env python
import bs4
def convert_element(lines, level=1):
result = ''
for line in lines:
if not isinstance(line, bs4.element.Tag) or \
line.name != 'outline':
continue