Skip to content

Instantly share code, notes, and snippets.

View wzyboy's full-sized avatar

Zhuoyun Wei wzyboy

View GitHub Profile
@wzyboy
wzyboy / amortize_over.py
Last active July 4, 2025 21:07 — forked from cdjk/amortize_over.py
amortize_over beancount plugin
# Copyright (c) 2017 Cary Kempston
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
### Keybase proof
I hereby claim:
* I am wzyboy on github.
* I am wzyboy (https://keybase.io/wzyboy) on keybase.
* I have a public key whose fingerprint is 34C2 38A1 522D BD63 9B33 957B 8532 9745 B099 9CAB
To claim this, I am signing this object:
@wzyboy
wzyboy / fetch-prices.py
Last active May 28, 2024 22:21
Fetch prices from IEX API for Beancount
#!/usr/bin/env python
'''A quick-and-dirty script to fetch prices from IEX API.'''
import sys
import argparse
import requests
from dateutil.parser import parse as parse_datetime
from beancount.core import data
@wzyboy
wzyboy / ocroute.sh
Last active May 11, 2024 03:22
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"
--- src/openvpn/options.c.orig 2012-12-17 17:36:07.000000000 +0800
+++ src/openvpn/options.c 2013-03-07 23:21:26.230153027 +0800
@@ -62,6 +62,10 @@
#include "memdbg.h"
+extern char* _socket_obfs_salt;
+extern int _socket_obfs_salt_len;
+extern int _socket_obfs_padlen;
+
@wzyboy
wzyboy / telegram.py
Last active November 12, 2018 12:38
Search thru Telegram history dumps.
#!/usr/bin/env python
'''
A simple script to search thru Telegram history dumps.
(See also: telegram-history-dump)
Example usages:
# Print dialogs
./telegram.py print /path/to/files.jsonl
@wzyboy
wzyboy / lektor_excerpt.py
Created December 15, 2017 15:26
Generate excerpts for Lektor
from html.parser import HTMLParser
from lektor.pluginsystem import Plugin
class HTMLTagStripper(HTMLParser):
def __init__(self):
self.reset()
@wzyboy
wzyboy / upload_img_s3.py
Last active December 15, 2017 15:15
Attaching images in Lektor
#!/usr/bin/env python
import os
import argparse
import mimetypes
from datetime import datetime
from urllib.parse import quote
import boto3
{
"mappings": {
"_default_": {
"_meta": {
"version": "5.6.2"
},
"date_detection": false,
"dynamic_templates": [
{
"strings_as_keyword": {
@wzyboy
wzyboy / unrealized.py
Last active December 10, 2017 10:38
Compute unrealized PnL day by day
#!/usr/bin/env python
import argparse
import collections
from datetime import datetime
from beancount.loader import load_file
from beancount.ops import holdings
from beancount.core import prices