Skip to content

Instantly share code, notes, and snippets.

View yymao's full-sized avatar

Yao-Yuan Mao yymao

View GitHub Profile
class Name(object):
"""
For better name comparison
"""
def __init__(self, name, exact=False):
self.name = name
if ',' in name:
name = '{0[1]} {0[0]}'.format(name.split(','))
self.names = tuple((n.lower() for n in name.replace('-', ' ').replace('.', '. ').split() if n != '.'))
assert self.names, '*name* must not be empty'
@yymao
yymao / hyperlink-year-only-natbib-patch.tex
Last active January 4, 2024 21:19
hyperlink-year-only-natbib-patch
@yymao
yymao / start-kernel-cli.py
Created December 3, 2018 16:25
start a bash that has the same environment as a jupyter kernel
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import subprocess
import json
import re
def abort(message, errorstatus=1):
@yymao
yymao / environment.yml
Last active December 6, 2024 15:36
My Python environment
# environment.yml
# Author: Yao-Yuan Mao @yymao
# Usage:
# wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
# sh Miniforge3-Linux-x86_64.sh
# wget https://gist.githubusercontent.com/yymao/a1fcd607925996d8786a1d963fb01deb/raw/environment.yml
# mamba env create --file environment.yml
name: mypy
channels:
@yymao
yymao / hlist2parquet.py
Created June 3, 2022 21:54
Convert hlist to parquet format
#/usr/bin/env python
import sys
import pyarrow as pa
import pyarrow.parquet as pq
from helpers.io_utils import hlist2pandas
import tqdm
def main(input_filename):
reader = hlist2pandas(input_filename, sanitize_column_names=True, chunksize=1000000)