List Only Subdirectories for Shell Scripting

I like to have the following snippet in my .zshrc (or .bashrc) for convenience

alias lsd="ls -l|awk '/^d/ {print \$9}'"

It displays all subdirectories underneath the current directory. The goodness in this variant is that it gives you the pure names and that you can use it in loops without hassle :

for d in `lsd`; do
mv $d/resultfile.dat $d_result.dat;
rmdir $d;
done

Finding out where your Program Crashes with the Emacs GUD

This post describes a very, very elementary debugging skill. Yet, I could not find any concise tutorial about it on the web. So, here we go!

Assume you’re developing a small software under Linux, maybe using C or C++ and the GCC compiler. Testing your program, you find that it crashes with an error (segfault, assertion, …). How do find the cause for this crash rapidly? How can you back-trace the error?

First, compile your program again adding the option “-g” (or “-gstabs“). The compiler (e.g. g++) will now include information necessary for debugging into your binary. Start Emacs and invoke “M-x gdb“. As parameter, enter the full path of your executable. You end up with something like “gdb --annotate=3 ~/myProject/myProgram“. In the newly opened buffer, set the commandline parameters as for example in “start --verbose-mode inputfile.dat“. Simply append the program options you normally use after “start“.

Run the command “c” (=continue). Your program will start - and crash. Now, invoke “M-x gdb-many-windows“. You will see the steps leading to the function that caused the crash in the window “stack frames”. By clicking on each of the steps, Emacs will directly navigate to the respective source code block, enabling you to trace the cause of the error. Find a more extensive tutorial here.

Economic Crisis coming faster than Great Depression

Since weeks  the media is reporting about the severity of the current economic crisis, comparing it with the Great Depression (GD) that began 1929. However, to me this seemed like a historic exaggeration since I couldn’t really rediscover the severe effects of the GD in the current crisis. However, I now found some figures that changed my mind.

In this article, the authors compare different economic metrrices of both times. The astonishing image that emerges is that the current crisis has already reached a great deal of the intensity of GD, but much faster. For example, we have already reached about 70% of the decrease in stock market value and about 35% of the decrease in world industrial output compared to the worst values during great depression. I find that a quite surprising result considering  the known social and political consequences of the GD. (Figure courtesy of Zeit Online)

Stock Market Comparison (Zeit Online Graphics)

Stock Market Comparison (from Zeit Online)

Including Math Formulas Into Emails

Today I stumbled over a very neat extension for the email client Mozilla Thunderbird. It allows you to include LaTeX style formulas into your email. Simply write down the formula enclosed in $$’s, e.g. $$\alpha = 5$$. Hitting a button will then convert all formulas into images and thereby allows you to send the email to any collegue that uses a HTML-understanding email client. Find the “Equations” extension here.

Online Memorizing Revisited

In december, I wrote an article about spaced repetition systems for learning vocabuly and other facts. The both web- and desktop-based tool Anki turned out to be particularly suitable for our purposes (see older post). One requirement was the ability to instantly share entered facts among a group of people, which interestingly was problematic for all tested tools.

We now found out that this feature is no poblem at all with Anki, which allows to subscribe to facts-sets (decks) of other people. This process is designed such that changes to shared decks propagate (see this discussion). In other words, once you subscribe to a deck, you will receive both corrections of existing facts and newly added facts. However, facts will not be deleted. So, just do as follows to get complete and instant sharing of facts among a group. One person -let’s call him master - sets up an initial deck and sends the share-key (to be found under Decks->share in the webinterface) to all other people in the learning group. Each of them subscribes to the master’s deck and sends his or her own share-key back to the master. The master now subscribes to all other decks. In effect, each group member can add and modify facts that will propagate to all other members. Perfect!

Fetch Bibliographic Data within Emacs

Are you frequently working with bibliographies, e.g. writing LaTeX documents with BibTeX? Finding the references you want to cite, and fetching/inserting the bibliographic data usually involves a number of clicks and database searches. There is an Emacs extension that may help you out here: Pub-Mode streamlines the whole process down to a couple of keystrokes.

Also, as he reported on a conference I attended recently, the author of Pub-Mode is developing a Bibliographic Management System that, amongst other things, automtically fetches the PDF-file of a reference. No more clicking through publishers websites. I’m really waiting for this one!

Using Emacs Org-mode to Draft Papers

Scientific papers are mostly written in LaTeX, a markup language for typesetting. With LaTeX, a document is programmed rather than edited in a WYSIWYG-way. There is a great deal of specialized editors or editor modes (e.g. AucTeX) simplifying the creation of LaTeX documents. In many cases, however, you just want to quickly write down what’s in your head instead of getting stuck in the details of LaTeX markup. I found that Emacs org-mode is very well suited to fill that gap. You can efficiently draft a scientific document that can directly be converted into LaTeX code which you can beautify later on. I’ll show you here how.

Read more »

Directly Edit and Play with Plots in R

The R-project describes itself as a “free software environment for statistical computing and graphics”. It can produce nice graphics indeed, but in practice editing them often gets tedious since any alteration must be given as one or multiple command-line commands. At least I thought so - until I found out about the playwith package. With it, you can play with any kind of graphic (plots, histograms, images…) interactively: zoom in/out, add text, modify colors and more. You can even add input elements (sliders, buttons,…) to interactively control any variable you’re using. The resulting graphics can be exported directly (hint: set output format with playwith.options(save.as.format = "svg") ). Try the package out: Playwith at Google Code.

Activate extended globbing!

This one is for zsh users. As you read this, open your editor at once an add the following line to your .zshrc

setopt extendedglob

This will activate extended globbing and allow you to do even more zsh commandline candy. Here some examples

rm ^important.txt # remove all files in the current dir but important.txt
rm *.log~apache.log # remove all .log-files except apache.log
ls (#a1)blu.dat # shows all files with one type error distance to blu.dat, e.g. bla.dat, blu.dot, bl.dat, ...

More possibilities are shown at man zshexpn | less -p 'Glob Qualifiers' or at the Zsh Lovers Page.

Schau mal: Frost!

Eine Kältewelle erschüttert das sonst so frostresistente Leipzig! Letztes Jahr haben Passanten noch erstaunt die Digitalkamera herausgeholt als sich etwas Schnee auf den Tischen der Gemüsehändler sammelte. Und nun: Schneeberge auf den Gehwegen und fast -20°C. Folgender Temperaturverlauf muss deshalb einfach ins Archiv.

Temperaturverlauf in Leipzig

Temperaturverlauf in Leipzig