Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meng-xu-cs committed Mar 18, 2022
0 parents commit 4450961
Show file tree
Hide file tree
Showing 95 changed files with 12,430 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
*~
*.aux
*.fdb_latexmk
/*.bak
/*.bbl
/*.blg
/*.dvi
/*.fls
/*.log
/*.out
/*.toc
/*.pdf
/die.tar.gz
/rev.tex
/abstract.txt
/code/*.tex
!/code/fmt.tex
!/figs/*.pdf
!/figs/*.eps
!/data/*.pdf
!/data/*.eps
.latexrun.db
/target
19 changes: 19 additions & 0 deletions .latexmkrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$bibtex = "bibtex -min-crossrefs=99";

push @cus_dep_list, "c tex 0 c2tex";
push @cus_dep_list, "cc tex 0 cc2tex";
push @cus_dep_list, "js tex 0 js2tex";
push @cus_dep_list, "py tex 0 py2tex";
push @cus_dep_list, "svg pdf 0 svg2pdf";
push @cus_dep_list, "plt tex 0 plt2tex";
push @cus_dep_list, "gp tex 0 gp2tex";
push @cus_dep_list, "dat gp 0 gp2tex";

sub c2tex { system("pygmentize -P tabsize=4 -P mathescape -f latex $_[0].c > $_[0].tex"); }
sub cc2tex { system("pygmentize -P tabsize=4 -P mathescape -f latex $_[0].cc > $_[0].tex"); }
sub js2tex { system("pygmentize -P linenos=1 -f latex $_[0].js > $_[0].tex"); }
sub py2tex { system("pygmentize -P tabsize=4 -P mathescape -f latex $_[0].py > $_[0].tex"); }
sub js2tex { system("pygmentize -P linenos=1 -f latex $_[0].js > $_[0].tex"); }
sub svg2pdf { system("inkscape --without-gui -f $_[0].svg -D -A $_[0].pdf"); }
sub gp2tex { system("gnuplot $_[0].gp"); }

73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
MAIN ?= p
DIFF ?= HEAD^
CODE := $(addsuffix .tex,$(filter-out %.tex,$(wildcard code/*)))
FIGS := $(patsubst %.svg,%.pdf,$(wildcard fig/*.svg))
ODGS := $(patsubst %.odg,%.pdf,$(wildcard fig/*.odg))
PLOT := $(patsubst %.gp,%.tex,$(wildcard data/*.gp))
DEPS := rev.tex code/fmt.tex abstract.txt $(CODE) $(FIGS) $(ODGS) $(PLOT)
LTEX := --latex-args="-shell-escape"
BTEX := --bibtex-args="-min-crossrefs=99"
SHELL:= $(shell echo $$SHELL)

all: $(DEPS) ## generate a pdf
@TEXINPUTS="sty:" bin/latexrun $(LTEX) $(BTEX) $(MAIN)

submit: $(DEPS) ## proposal function
@for f in $(wildcard submit-*.tex); do \
TEXINPUTS="sty:" bin/latexrun $$f; \
done

diff: $(DEPS) ## generate diff-highlighed pdf
@bin/diff.sh $(DIFF)

help: ## print help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'

rev.tex: FORCE
@printf '\\gdef\\therev{%s}\n\\gdef\\thedate{%s}\n' \
"$(shell git rev-parse --short HEAD)" \
"$(shell git log -1 --format='%ci' HEAD)" > $@

code/%.tex: code/% ## build highlighted tex code from source code
pygmentize -P tabsize=4 -P mathescape -f latex -o $@ $^

code/fmt.tex: ## generate color table
pygmentize -f latex -S default > $@

fig/%.pdf: fig/%.svg ## generate pdf from svg
inkscape --without-gui -f $^ -D -A $@

fig/%.pdf: fig/%.odg ## generate pdf from LibreOffice Draw
soffice --convert-to pdf $< --outdir $(@D)
pdfcrop $@ $@

data/%.tex: data/%.gp ## generate plot
gnuplot $^

draft: $(DEPS) ## generate pdf with a draft info
echo -e '\\newcommand*{\\DRAFT}{}' >> rev.tex
@TEXINPUTS="sty:" bin/latexrun $(BTEX) $(MAIN)

watermark: $(DEPS) ## generate pdf with a watermark
echo -e '\\usepackage[firstpage]{draftwatermark}' >> rev.tex
@TEXINPUTS="sty:" bin/latexrun $(BTEX) $(MAIN)

spell: ## run a spell check
@for i in *.tex fig/*.tex; do bin/aspell.sh $$i; done
@for i in *.tex; do bin/double.pl $$i; done
@for i in *.tex; do bin/abbrv.pl $$i; done
@bin/hyphens.sh *.tex
@pdftotext $(MAIN).pdf /dev/stdout | grep '??'

clean: ## clean up
@bin/latexrun --clean
rm -f abstract.txt

distclean: clean ## clean up completely
rm -f code/*.tex

abstract.txt: abstract.tex $(MAIN).tex ## generate abstract.txt
@bin/mkabstract $(MAIN).tex $< | fmt -w72 > $@

.PHONY: all help FORCE draft clean spell distclean init
90 changes: 90 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# DieHard: A Presentation Template

## start

0. Prerequisites

- Python 3.x
- pygmentize

$ pip install Pygments

1. clone the git repo:

- if you have none,

$ git clone --depth=1 [email protected]:tsgates/die.git

- if you have a git-repo to work on,

$ git subtree add --squash [email protected]:tsgates/die.git master -P paper

- or

$ wget https://github.com/tsgates/die/releases/download/latest/die.tar.gz

2. build it:

$ make
p.pdf built @Tue May 20 20:38:19 EDT 2014

(check p.pdf)

3. starting point, p.tex:

$ grep -oP 'input{\K\w+' p.tex
cmds
rev
*hdr
abstract
*ex
intro
overview
design
impl
eval
conclusion
ack

- hdr: includes title/author info
- ex : includes latex examples

4. example latex

$ git checkout example
$ make

5. formatting rules (dependencies)

- code/*.{c,cc,py,js ...} -> code/*.tex
- fig/*.svg -> fig/*.pdf
- data/*.gp -> fig/*.tex

(see ex.tex for more details)

## tools

1. make a draft for revision

$ make draft
$ make watermark

2. abstract.txt (from abstract.tex)

$ cat abstract.txt

3. highlight changes, since the last submit

$ make diff DIFF=HEAD@{}

4. spell check

$ make spell

## Acknowledgment

This template contains many files copied/stolen from the Internet and
mainly from my past collaborators (e.g., sty/*, conf.bib, some bin/),
which I couldn't keep track of their licenses. A special thanks goes
to "die: a paper template" available at https://github.com/tsgates/die
which I have enjoyed a lot while working at SSLab.
3 changes: 3 additions & 0 deletions abstract.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\begin{abstract}
\sys
\end{abstract}
13 changes: 13 additions & 0 deletions aspell.words
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
personal_ws-1.1 en 12
ACL
Baidu
Dropbox
EndoApp
LimeGreen
OneDrive
TK
TODO
baz
dat
init
svg
11 changes: 11 additions & 0 deletions bin/abbrv.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/perl
# Detects potential abbreviations at the end of a sentence.

while (<>) {
s/%.*//;
next unless s/([A-Z]+\.)/\e[7m$1\e[m/g;

s/^([^\e]*\n)+//mg;
s/^/$ARGV: /mg;
print;
}
41 changes: 41 additions & 0 deletions bin/aspell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

DIC=$(dirname "$0")/../aspell.words
TEX=$1

# p: skip a param
# P: don't skip a param
# o: skip an optional param
# O: don't skip an optional param
TEXCMD=(--add-tex-command="autoref p"
--add-tex-command='begin pop'
--add-tex-command='bibliography p'
--add-tex-command='bibliographystyle p'
--add-tex-command='cc p'
--add-tex-command='citeauthor p'
--add-tex-command='color p'
--add-tex-command='definecolor ppp'
--add-tex-command='eqref p'
--add-tex-command='fvset p'
--add-tex-command='hypersetup p'
--add-tex-command='lstset p'
--add-tex-command='mathit p'
--add-tex-command='mathrm p'
--add-tex-command='includeplot p'
--add-tex-command='includepdf p'
--add-tex-command='therev p'
--add-tex-command='newcommand pp'
--add-tex-command='renewcommand pp'
--add-tex-command='usetikzlibrary p'
--add-tex-command='DeclareMathOperator pp'
--add-tex-command='VerbatimInput p'
--add-tex-command='includefig pp')

touch $DIC
aspell --lang en -x --mode=tex "${TEXCMD[@]}" -p $(pwd)/$DIC -c $TEX

VER=$(head -1 $DIC)
tail -n +2 $DIC | LC_ALL=C sort > $DIC~

echo $VER > $DIC
cat $DIC~ >> $DIC
24 changes: 24 additions & 0 deletions bin/diff.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -x

ROOT=$(git rev-parse --show-toplevel)
TMPD=$(mktemp -d /tmp/latexdiff.XXXXXXXXXX)
HERE=$(realpath --relative-to=$ROOT $(pwd))

mkdir -p $TMPD

OLD_REPO=$TMPD/old

git clone $ROOT $OLD_REPO

cd $OLD_REPO
git checkout $1

NEWD=$ROOT/$HERE
OLDD=$OLD_REPO/$HERE

cd $OLDD
make
latexdiff --flatten p.tex $NEWD/p.tex > diff.tex

make MAIN=diff
cp -f diff.pdf $NEWD/diff.pdf
17 changes: 17 additions & 0 deletions bin/double.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/perl

# Detects duplicated words even when they are
# are repeated between lines.
# Taken from the ORA regex book

$/ = ".\n";
while (<>) {
next if !s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig;

s/^([^\e]*\n)+//mg;
s/^/$ARGV: /mg;
print;
}

# also test for things like
# [^\w+]a\w+[aeiou] and [^\w+]an\w+[!aeiou]
20 changes: 20 additions & 0 deletions bin/get-tex-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh

FLIST="$1"

while :;
do
LAST="$FLIST"
for F in $LAST; do
NL=`cat $F | grep \\input{ | grep -v ^% | cut -d{ -f2 | cut -d} -f1`
for F2 in $NL; do
FLIST="$FLIST $F2.tex"
done
done
FLIST=`ls $FLIST | sort | uniq`

if [ "$LAST" = "$FLIST" ]; then
echo $LAST
exit 0
fi
done
10 changes: 10 additions & 0 deletions bin/hyphens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

if [ "$1" = "" ]; then
echo "usage: `basename $0` <file> ..."
exit
fi

grep --color ly- "$@"
exit 0

Loading

0 comments on commit 4450961

Please sign in to comment.