Archive for the 'Progs/Tools/Libs' Category

The ultimate Latex Makefile

Friday, March 24th, 2006

After a long time of trial and errors (a.k.a. procrastination), I finally finished my “make phd” script for my thesis. The script uses bibtex (rerunning Latex as many times as needed) and can use either Latex or PDFLatex (if you want to use hyperref and nice PDF stuff) and if necessary converts all your images to PDFs.

You can use it like this:

make all                 <- build the document using latex, dvips, epstopdf
make clean             <- clean up (remove all intermediate (and final), including converted eps images (in using pdflatex)
PDF=true make all    <- builds the document using PDFLatex

Here’s the main makefile:

Makefile for Tadek's thesis

This file builds a paper - PDF file and if (PDF is defined) a PDF with hyperlinks

#

Written (c)2005 by Tadeusz Pietraszek (pie@zurich.ibm.com)

$Id: Makefile 597 2006-01-12 15:43:59Z pie $

#

Egrep trick from: http://xpt.sourceforge.net/techdocs/Latex/

MakefileForTeX/Latex08.000.html

TEXFILES=thesis.tex

TEXFILES=$(wildcard *.tex)

TARGETS=$(patsubst %.tex,%.pdf,$(TEXFILES))

RERUN = "(There were undefined references|Rerun to get (cross-references|the bars) right)" RERUNBIB = "No file..bbl|Citation.undefined"

phd: all

all: all-recursive $(TARGETS)

clean: clean-recursive rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg \ *.inx *.ps *.dvi *.pdf *.toc *.out *.lot *~ *.backup

all-recursive: for dir in $(wildcard *); do if [ -d $$dir ] && [ -f $$dir/Makefile ]; then cd $$dir; $(MAKE) all; cd ..; fi; done

clean-recursive: for dir in $(wildcard *); do if [ -d $$dir ] && [ -f $$dir/Makefile ]; then cd $$dir; $(MAKE) clean; cd ..; fi; done

ifndef PDF

building the document using .dvi, .ps, -> .pdf

%.dvi: %.tex echo $(SHFILES) latex $< egrep -c $(RERUNBIB) $.log && (bibtex $;latex $<); true egrep $(RERUN) $.log && (latex $<) ; true egrep $(RERUN) $.log && (latex $<) ; true

%.ps: %.dvi dvips -Ppdf -ta4 -G0 $<

%.pdf: %.ps ps2pdf $<

else

this is making the same file using pdfelatex

%.pdf: %.tex pdfelatex $< egrep -c $(RERUNBIB) $.log && (bibtex $;pdfelatex $<); true egrep $(RERUN) $.log && (pdfelatex $<) ; true egrep $(RERUN) $.log && (pdfelatex $<) ; true

endif

My pictures are built using the following Makefile (in a subdirectory of the main paper):

Makefile for Tadek's thesis - pictures!

#

Supports two targets: all and clean - and calls other makefiles recursively

If PDF is defined, converts EPS into PDFs

#

$Id:$

#

If you want to add your custom grpahic file .foo you need to

#

FOOFILES=#(wildcard *.foo)

EPSFILES=... $(patsubst %.foo,%.eps,$(FOOFILES))

#

%.eps: %.foo:

foo2eps -o $*.eps $<

source files

DIAFILES=$(wildcard *.dia) INKSCAPEFILES=$(wildcard *.svg)

target files (only those that we are building, and will be deleted)

EPSFILES=$(patsubst %.dia,%.eps,$(DIAFILES)) $(patsubst %.svg,%.eps,$(INKSCAPEFILES))

ifdef PDF

target files (if we're building PDFs)

PDFFILES=$(patsubst %.eps,%.pdf,$(EPSFILES) $(wildcard *.eps)) else PDFFILES= endif

Editing Python programs in VI

Monday, March 6th, 2006

I recently discovered that if you have to edit your python code from vi, the following definiton is very useful:

:se et ts=8 sw=4 softtabstop=4 smarttab

But other than certain rare cases, I’d recommend to run PyDev in Eclipse. There’s also a nice tutorial if you need it.

  • findbugs is an interesting opensource project doing static bytecode analysis to find bugs in Java programs. Looks very interesting. And here is a scientific paper comparing and empirically evaluating different bug finders for Java. (0)

GeoLocating IP addresses for free

Sunday, February 26th, 2006

I found out that MaxMInd provides a GeoLiteCity – a free(!) database for geolocating of IP addresses. You get to download a binary database (24MB) (monthly updated) and GPL libraries to perform lookups. They offer libraries for serveral languages including PHP, Perl, Python and Ruby.

I must say I am really impressed, a company offering such a database for free with really high quality tools (e.g., the bindings use auto{make|conf} tools and are really easy to install).

Where’s the catch? Well, they say that the database offers 60% accuracy – the commercial database ($370 plus $90 a month) offers 75% accuracy, plus more detailed info (ISP, postcode, area codes, etc). Anyways, it’s more than enough for my website statistics. Now displaying my visitors using GoogleMaps is a one evening work ;-)

Here’s a sample output of my DSL IP address and my server:

./geoiplookup 217.162.130.229
GeoIP Country Edition: CH, Switzerland
GeoIP City Edition, Rev 1: CH, 25, Langnau, (null), 47.283298, 8.533300, 0, 0
GeoIP City Edition, Rev 0: CH, 25, Langnau, (null), 47.283298, 8.533300

./geoiplookup tadek.pietraszek.org
GeoIP Country Edition: DE, Germany
GeoIP City Edition, Rev 1: DE, 02, Gunzenhausen, (null), 49.099998, 10.750000, 0, 0
GeoIP City Edition, Rev 0: DE, 02, Gunzenhausen, (null), 49.099998, 10.750000

Well done, guys and a really good marketing idea.

TaskJuggler – a project planner software

Tuesday, January 24th, 2006

TaskJuggler is an extremely powerful open-source project management software. Unlike other tools of this sort it is almost completely text-file driven and batch mode (yes, it has a nice GUI as well, but the operation is editing of the text project file). Also, the reports it generates are completely scriptable (actually there’s no other way of doing them). This is different from you’d expect, but maybe for us geeks it’s better to have something that works this way? ;-)

It is really powerful and looks actually usable (unlike some other open-source projects like planner, which aspire to be but are IMO not even close).

Additional advantages I see are: - easy to track changes if you keep the project file in CVS/SVN - can easily script it, so that you can see your project status on the website?

Maybe I will use one day? ;-)

BetterShoppper FireFox plugin

Saturday, January 21st, 2006

Bettershopper is a really cool plugin showing doing automatic price comparisons on amazon.com for a number of amazon.XX, alibris or other sites and converts them to your favorite currency. Saves a lot of time and money ;-)

I’ve been using version 1.1, which at some point stopped working :-( Now I discovered that version 1.2 is on its way and you can download 1.2beta2, which works great for me (you can get it here). BTW: it also works with FireFox 1.5.

Great idea and execution. Well done! Looking forward to trying 1.2 out!

Intuitive table layouting in Latex (package tabulary)

Wednesday, January 11th, 2006

While writing my paper I found out a nice page table layouting package – tabulary). If has the following advantages over tabularx:

  1. The results are “intuitive”, i.e. the table columns can be scaled proportionally to their original width (it takes some manual tricks to make X with different widths). This is similar to HTML rendering in the browser.
  2. Yet you can specify maximum and minimum width for layouting to avioid overly imbalanced tables.
  3. You can use various aligning (C, L, R does exactly what you think it does).
  4. Obviously, similarly to tabularx you can mix the variable-width columns with fixed width ones.

The only problem was that tabulary (v.0.8) didn’t work well for me in all cases. I looked a bit into the code and I think I found the bug (I’m not a TeX expert, so I’m not sure, but it works for me now). The fix is the following one-line patch file:

--- tabulary.dtx        2006-01-11 15:45:03.000000000 +0100
+++ tabulary.dtx.orig   2006-01-11 15:44:29.000000000 +0100
@@ -599,7 +599,7 @@
   \let\TY@checkmin\relax
 \ifdim\TY@tablewidth>\z@
   \Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth
- \ifdim\TY@tablewidth <\TY@linewidth
+ \ifdim\TY@tablewidth <\linewidth
    \def\TY@ratio{1}%
  \fi
 \else

Converting JARs to executables (JAR to EXE)

Thursday, December 22nd, 2005

Recently, I found out that Java the program I wrote ages ago has been alive and kicking and, even more, distributed as a single EXE with an install program. I was a bit surprised, as the last stage I left it it, was only a JAR file (with no sources available) ;-)

Looking a bit into it I found out how it can be easily done, which may be useful one day. Not that I want to write Windows programs, but…

  • The installation can be done using Install Creator. The freeware version displays a small ad at the end of the process, but otherwise is free and looks ok.
  • For the Java-to-EXE conversion there’s a nice comparison and discussion. In this particular case they used exe4j, which is commercial, but there’s a number of other free tools around.

All in all, I must admit they did a good job making my program more user friendly and easier to use. It’s probably a good idea if your target users use a Windows platform (my original program is portable, but I’ve never seen anyone use it on anything but Windows)…

  • Ruby on Rails it looks like a very cool framework. I really like the scrict M -V-C separation and of cource the AJAX library. (BTW the REST-like concept reminds me of mod_python). Ruby off Rails a nice, though superficial comparison with Java. (0)
  • Gubed PHP Debugger – looks cool and has got a nice GUI – may prove useful some time. (0)