Skip to content

Instantly share code, notes, and snippets.

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

Zhitao Gong gongzhitaao

🐢
(๑•̀ㅂ•́)و✧
  • DeepMind
  • Montreal, CA
  • 21:25 (UTC -05:00)
View GitHub Profile
@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 ([email protected])
;; 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 / mnt.sh
Created September 27, 2012 06:33
Mount texlive
mount -t iso9660 -o ro,loop,noauto /your/texlive2012.iso /mnt
@gongzhitaao
gongzhitaao / vbox
Created November 9, 2012 09:53
usb token
#+STARTUP: noindent
问题:VirtualBox成功安装Win7后无法识别招行网银
系统:Ubuntu12.04 prices,VirtualBox4.1.12
依次设置:
1 增加当前用户对usb的操作权限:
$sudo lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
@gongzhitaao
gongzhitaao / .emacs
Created November 15, 2012 02:27
dotemacs by Bill Clementson
;;; .emacs - an emacs initialization file created by Bill Clementson
;;__________________________________________________________________________
;;;; Site-Specific Variables
;; See if we're on MS Windows or some other OS
(defvar mswindows-p (string-match "windows" (symbol-name system-type)))
(defvar macosx-p (string-match "darwin" (symbol-name system-type)))
;; Some file locations are relative to the HOME or the BIN directory
--- CGAL-3.4/include/CGAL/Interval_nt.h
+++ CGAL-3.4/include/CGAL/Interval_nt.h
@@ -149,11 +149,13 @@
// The macros CGAL_IA_MUL and CGAL_IA_DIV stop constant propagation only
// on the second argument, so if -fno-rounding-math, the compiler optimizes
// the 2 negations and we get wrong rounding.
+#if 0
typename Interval_nt<>::Internal_protector P;
CGAL_assertion_msg(-CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1),
"Wrong rounding: did you forget the -frounding-math option if you use GCC?");
<script type="text/javascript">// <![CDATA[
function callTheJsonp()
{
// the url of the script where we send the asynchronous call
var url = "http://localhost/utils/jsonp/ajax.php?callback=parseRequest";
// create a new script element
var script = document.createElement('script');
// set the src attribute to that url
script.setAttribute('src', url);
// insert the script in out page
@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 / convolution-parallel-mpi.cpp
Last active December 25, 2015 09:59
Simple sequential and parallel implementation of convolution in C++
#include <fstream>
#include <mpi.h>
inline double convolute(double **img, const double (*w)[11],
int r, int c)
{
double s = 0;
for (int i = 0; i < 11; ++i)
for (int j = 0; j < 11; ++j)
s += img[r-5+i][c-5+j] * w[i][j];
@gongzhitaao
gongzhitaao / clsfunccnt
Last active December 25, 2015 13:19
1. Count lines of code (LOC),, excluding blank lines and comments 2. Count number of methods in a class
#!/bin/bash
# usage: ./clsfunccnt <directory> <filename-regex> <classname>
find $1 -regex "$2" -exec cat {} \; | \
sed -n "
# find target class
/^class\s\+$3:/,/^class.*/{
# print all def's with 4 spaces indent
/\s\{4\}def\s\+.*/p
@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.