Skip to content

Instantly share code, notes, and snippets.

View chaserhkj's full-sized avatar

Kangjing "Chaser" Huang chaserhkj

  • West Lafayette, IN, United States
View GitHub Profile
@chaserhkj
chaserhkj / xoauth2.patch
Last active October 21, 2023 07:57
Patch for ssmtp to support safer XOAuth2 authentication (see comment for details)
Adds XOAUTH2 functionality for safer authentication.
Still needs a separate script/service to obtain and refresh OAUTH2
access token for most mail providers.
Patch by Moriyoshi Koizumi <mozo@mozo.jp>
Modified by Kangjing Huang <huangkangjing@gmail.com>
diff --color -u ssmtp-2.64.orig/ssmtp.c ssmtp-2.64/ssmtp.c
--- ssmtp-2.64.orig/ssmtp.c 2023-10-21 00:39:18.895976193 -0400
#!/usr/bin/python
import sh
import os, sys
import time
shx = sh(_out=sys.stdout, _err=sys.stderr)
eprint = lambda p: print(p, file=sys.stderr)
# Masks are for configuring kernel writeback worker mask
# Full core usages
TOTAL_CORES_MASK="ffff"
@chaserhkj
chaserhkj / rename.py
Created January 1, 2020 02:16
Renaming files with too long a filename, useful on EncFS
import os, sys
import hashlib
THRESHOLD = 100
DRY=True
def main(d_path):
d_base = os.path.dirname(d_path)
d_name = os.path.basename(d_path)
h_path = d_path
if len(d_name.encode('utf8')) > THRESHOLD:
@chaserhkj
chaserhkj / 60833864-transition-statement.txt
Created September 26, 2018 16:32
GPG Key 60833864 Transition Statement
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Wednesday, Jun 6 2018, 00:10, +0400
For a number of reasons, I've recently set up a new PGP key
and will be transitioning away from my old one.
The old key will continue to be valid for a short period after
the posting of this message, but future signatures will be

Keybase proof

I hereby claim:

  • I am chaserhkj on github.
  • I am chaserhkj (https://keybase.io/chaserhkj) on keybase.
  • I have a public key ASABTRJmAmTqcye0DInkWX6q29o-D2IWlcA_WI2VNfWEPQo

To claim this, I am signing this object:

@chaserhkj
chaserhkj / MplTplt.tex
Last active March 8, 2021 07:35
Yet another LaTeX template for Modern Physics Lab, PKU. NO LONGER MAINTAINED HERE, PLEASE SEE https://github.com/chaserhkj/ModPhyLab
% MplTplt - Yet another LaTeX template for Modern Physics Lab, PKU.
% Copyright (C) 2014 Huang Kangjing and contributors
% This work is completely rewritten basing on the work of Cao Chuanwu
% and Sun Sibai, with texts in the template originally coming from the
% Modren Phys. Lab.
% This file is released under the MIT license.
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@chaserhkj
chaserhkj / prop_class.py
Last active December 29, 2015 05:39
A simple python module using class generator and metaclass techniques to create python property class in an elegant and efficient way.
#!/usr/bin/env python2
#
# Copyright (C) 2013 Chaserhkj
#
# 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: