Skip to content

Instantly share code, notes, and snippets.

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

Zhitao Gong gongzhitaao

🐢
(๑•̀ㅂ•́)و✧
  • DeepMind
  • Montreal, CA
  • 12:15 (UTC -04:00)
View GitHub Profile
@gongzhitaao
gongzhitaao / sed-one-liner
Created October 23, 2013 02:43
sed one-liner
# input:
# 1 1
# 2 2
# 3 3
# 4 4
# 5 5
# 6 6
# 7 7
# output:
# 1
@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 / README.md
Last active August 29, 2015 14:00
I'm a demo

This is a demo gist to test my gist viewer. The Javascript may not be written by me :D

This is a test for update.

var svg = document.querySelector( "svg" );
var svgData = new XMLSerializer().serializeToString( svg );
var canvas = document.createElement( "canvas" );
var ctx = canvas.getContext( "2d" );
var img = document.createElement( "img" );
img.setAttribute( "src", "data:image/svg+xml;base64," + btoa( svgData ) );
img.onload = function() {
@gongzhitaao
gongzhitaao / README.md
Last active January 4, 2025 03:38
Analog Clock

Simple analog clock.

@gongzhitaao
gongzhitaao / README.md
Last active August 29, 2015 14:02
Game of life
@gongzhitaao
gongzhitaao / README.md
Last active August 29, 2015 14:03
Maze DFS

A maze pattern is generated by Depth-First Search (DFS) algorithm. To create more interesting/skewed maze, the probability to search for each direction, i.e. top, right, down and left is randomized. As a result sometimes it's more likely to go upward, if available, than right. This generator could be found in mazejs.

@gongzhitaao
gongzhitaao / Makefile
Last active August 29, 2015 14:07
COMP 2710 Lab2
CXX=g++
EXE=main
FLG=-std=c++11 -O2 -Wall
all : $(EXE)
$(EXE) : main.cpp
$(CXX) $(FLG) -o $@ $<
clean :
@gongzhitaao
gongzhitaao / maze.cpp
Last active August 29, 2015 14:08
COMP 2710 Lab 3
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <queue>
#include <vector>
#include <utility>
@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;
}