Skip to content

Instantly share code, notes, and snippets.

View xiaom's full-sized avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Goldsky
  • Canada
  • 22:25 (UTC -07:00)
View GitHub Profile
@xiaom
xiaom / gist:2722102
Created May 17, 2012 22:44
make file for pandoc to latex
draft:
pandoc -N --latex-engine=xelatex --template=template.tex def.markdown -o def.pdf --biblio def.bib
final:
pandoc -N --latex-engine=xelatex --template=template.tex def.markdown -o def.tex --biblio def.bib
bibtex def
xelatex def.tex
xelatex def.tex
@xiaom
xiaom / setfont.tex
Created May 21, 2012 23:34
set font in latex
\usetheme{default}
\usepackage{mathpazo}
\usepackage{fontspec}
\setbeamertemplate{background canvas}{\includegraphics [width=\paperwidth]{blackboard_bk.pdf}}
\newfontfamily\chalkd{Chalkduster.ttf}
\newfontfamily\chalkb{Chalkboard.ttc}
\setbeamerfont*{normal text}{family = \chalkd}
\setbeamerfont{alerted text}{family = \chalkd}
\setbeamerfont{structure}{family = \chalkd}
@xiaom
xiaom / alg.tex
Created June 2, 2012 17:31
algorithm2e template
\begin{figure}
% Manual: http://bit.ly/N5qECH
\begin{algorithm}[H]
\caption{$\textsc{AlgName}$}
\label{alg:foobar}
\SetAlFnt{\tiny \sf}
\SetCommentSty{textrm}
\SetKwComment{Comment}{~$\triangleright$~}{}
@xiaom
xiaom / multiline.tex
Created June 6, 2012 00:28
multiline equation
% http://tug.org/pracjourn/2006-4/madsen/madsen.pdf
\begin{align*}
\dbx &= \dbx[3cm] \\
&= \dbx
\end{align*}
\begin{equation}
\begin{split}
@xiaom
xiaom / crawl.sh
Created June 11, 2012 01:37
extract from toc.html
perl -n -e '/(http:\/\/community.livejournal.com\/clinic_duty\/[0-9]+.html)/ && print "$1\n"' toc.html | wget
@xiaom
xiaom / crawl.sh
Created June 11, 2012 01:40
crawl page for an index html
perl -n -e '/(http:\/\/community.livejournal.com\/clinic_duty\/[0-9]+.html)/ && print "$1\n"' toc.html | wc -l
@xiaom
xiaom / jeffe.sty
Created June 13, 2012 08:11
macros used by Jeff Erickson
% http://www.cs.uiuc.edu/~jeffe/pubs/latex.html
% ============================-*- LaTeX -*-=============================
%
% jeffe.sty -- macros I use everywhere
%
% Jeff Erickson (jeffe@cs.uiuc.edu)
% Last modified 22 May 2010
% This is free; caveat emptor!
%
% Requirements that may not be part of every TeX distribution:
@xiaom
xiaom / dup.js
Created July 16, 2012 22:55
eliminate duplicates in Javascript
function eliminateDuplicates(arr) {
var i,
len=arr.length,
out=[],
obj={};
for (i=0;i<len;i++) {
obj[arr[i]]=0;
}
for (i in obj) {
@xiaom
xiaom / pq.cpp
Created July 16, 2012 22:56
use priority queue
// top k denest regions: the k-th region is on the top
class RegionCmp {
public:
bool operator()(const Region& lhs, const Region& rhs) const {
return lhs.d > rhs.d;
}
};
typedef priority_queue<Region, vector<Region>, RegionCmp> RegionPQ;
@xiaom
xiaom / gencomb.py
Created February 15, 2013 20:01
generate combinations
# generate combinations
#
# http://docs.python.org/2/library/itertools.html#itertools.combinations
#
# combinations(iterable, r) --> combinations object
# Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)