Skip to content

Instantly share code, notes, and snippets.

View gongzhitaao's full-sized avatar
🐢
(๑•̀ㅂ•́)و✧

Zhitao Gong gongzhitaao

🐢
(๑•̀ㅂ•́)و✧
  • DeepMind
  • Montreal, CA
  • 18:30 (UTC -04:00)
View GitHub Profile
@gongzhitaao
gongzhitaao / py-logger-template.py
Last active May 1, 2024 18:08
Python logging template
import logging
import logging.config
from datetime import datetime
import os
import sys
LOGFILE = '/tmp/{0}.{1}.log'.format(
os.path.basename(__file__),
datetime.now().strftime('%Y%m%dT%H%M%S'))
@gongzhitaao
gongzhitaao / ebook.org
Last active March 24, 2024 08:52
Open book website collection

美国国家学术出版社所有 PDF 图书开放免费下载

美国国家学术出版社所有 PDF 图书开放免费下载美国的国家学术出版社 (National Academies Press,NAP)于2011年6月2日宣布,将其出版的所有 PDF 版图书对所有读者免费开放下载,并且将这些图书去除 DRM 保护。这其 中不仅包括超过4000种最新出版的图书,还包括已经提交报告将于未来一段时 间出版的图书。

国家学术出版社负责美国国家科学院(National Academy of Sciences)、美 国国家工程学院(National Academy of Engineering)、美国国家医学院

@gongzhitaao
gongzhitaao / CppTimer.md
Last active January 28, 2024 14:25
Simple high resolution timer in C++

A simple Timer class that provides satisfying resolution.

API

  • Timer() constructs the timer.
  • .reset() resets the timer
  • .elapsed() returns elapsed seconds in double since last reset.
@gongzhitaao
gongzhitaao / hs.conf.el
Last active November 30, 2022 07:59
hideshow config for emacs
(defface collapsed-face '((t (:background "#e0cf9f" :foreground "#5f5f5f"))) "Collapsed Overlay")
(defvar collapsed-face 'collapsed-face)
(define-fringe-bitmap 'hs-marker [0 24 24 126 126 24 24 0])
(defun display-code-line-counts (ov)
(when (eq 'code (overlay-get ov 'hs))
(let* ((marker-string "*fringe-dummy*")
(marker-length (length marker-string))
(display-string
(format " (%d)... "
@gongzhitaao
gongzhitaao / kmp.cpp
Last active January 4, 2022 08:07
KMP implementation in C++
int kmp(const string &T, const string &P) {
if (P.empty()) return 0;
vector<int> pi(P.size(), 0);
for (int i = 1, k = 0; i < P.size(); ++i) {
while (k && P[k] != P[i]) k = pi[k - 1];
if (P[k] == P[i]) ++k;
pi[i] = k;
}
@gongzhitaao
gongzhitaao / chinese-calendar.el
Created September 24, 2012 12:30
Emacs extension for chinese calendar
;;; chinese-calendar.el --- calendar for chinese
;; Copyright (C) 2004 Free Software Foundation, Inc.
;; Author: Charles Wang for the original version
;; Milton Wu(wulei) for the current version (miltonwulei@163.com)
;; Keywords: calendar, i18n
;; This file is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@gongzhitaao
gongzhitaao / COMP2710-2019.md
Last active June 4, 2019 18:56
COMP 2710 2019 Spring Grading Script

This gist contains all the grading script for COMP2710 2019 Spring session.

@gongzhitaao
gongzhitaao / CMakeLists.txt
Created October 7, 2013 04:23
A Minimum Working Example Using CMake to build project with Qt5 forms
# suppose you have created a ui file called configwin.ui
cmake_minimum_required (VERSION 2.6)
project(tst)
find_package(Qt5Widgets)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@gongzhitaao
gongzhitaao / 0tmp.png
Last active September 16, 2018 23:45
Plot top5 probabilities and labels
0tmp.png
@gongzhitaao
gongzhitaao / pytorch-print.py
Created September 16, 2018 18:52
Get output from intermediatelayers
from functools import partial
def foo(self, inp, out, name=''):
log.debug('layer name {}'.format(name))
log.debug('input size {}'.format(inp[0].size()))
log.debug('output size {}'.format(out[0].size()))
bar = partial(foo, name='Conv2d_1a_3x3')