Skip to content

Instantly share code, notes, and snippets.

View zhangt58's full-sized avatar

Tong Zhang zhangt58

  • 00:16 (UTC -04:00)
View GitHub Profile
@zhangt58
zhangt58 / wheel-action.sh
Created October 29, 2021 20:48
Build a wheel package from a git tracked Python repository, and publish it to PyPI
#!/usr/bin/env bash
#
# Build a wheel package from a git tracked Python repository,
# and publish it to PyPI.
#
# Tong Zhang, 2021-10-29
#
#
#!/usr/bin/env bash
#
# Tong Zhang <zhangt@frib.msu.edu>
# 2018-07-31 11:22:12 AM EDT
# Travis CI only
# after_success
# deploy gh-pages
#
@zhangt58
zhangt58 / utc2local.py
Created October 9, 2017 20:57
Convert UTC datetime into time at local timezone.
from datetime import datetime
import pytz
import tzlocal
local_timezone = tzlocal.get_localzone()
utc_time = datetime.utcnow()
local_time = utc_time.replace(tzinfo=pytz.utc).astimezone(local_timezone)
print(utc_time.strftime("%Y-%m-%d %H:%M:%S [%Z]"))
@zhangt58
zhangt58 / data_files.py
Created September 25, 2017 13:59
Prepare `data_files` for setup.py
def get_all_dirs(des_root, src_root):
ret = []
for r,d,f in os.walk(src_root):
ret.append(
(os.path.join(des_root, r), [os.path.join(r, fi) for fi in f])
)
return ret
@zhangt58
zhangt58 / docker-clean
Created September 5, 2017 13:42
Clean up docker images, or all docker data by option.
#!/bin/bash
#
# clean up docker images/data.
#
# Tong Zhang <zhangt@frib.msu.edu>
# 2017-08-25 08:47:34 AM EDT
#
print_help ()
@zhangt58
zhangt58 / replace.sh
Last active December 21, 2021 19:41
Code refactoring toolkit
#!/bin/bash
# Code refactoring tool:
#
# Replace $OLD with $NEW for files
#
# Tong Zhang <zhangt@frib.msu.edu>
# 2017-07-21 10:52:37 AM EDT
#
@zhangt58
zhangt58 / rsync_backup.py
Created March 25, 2017 23:56 — forked from seebk/rsync_backup.py
Python rsync backup script
#!/usr/bin/python3
#######################################################
# Python rsync Backup script
# Sebastian Kraft, 24.06.2013
#
#######################################################
#-----------------------------------------------------
# Config