“Snippet” is a programming term for a small region of re-usable source code or text.

Get easy statistics for C++ STL classes (or your own)

The files in File iconstats.tar.gz (2.29 KiB) allow you to do quick-and dirty descriptive statistics, especially together with boost lambda:

 1 #include <boost/lambda/lambda.hpp>
 2 #include <stats.hpp>
 4 ExactDescriptiveStatistics floatstat ("Float  : ");
 6 for (float f=0.f; f<10.f; f++)
 7     floatstat+=f;
 9 ExactDescriptiveStatistics intstat ("Ints  : ", intvec.begin(), intvec.end());
11 ExactDescriptiveStatistics tstat ("Thresholds  : ");
12 tstat.notify(vec.begin(),vec.end(),bind(&Neuron::mThreshold,_1));
14 cout << tstat << endl << intstat << floatstat << endl;

Draw boxplots for columns in datafiles.

The perl-script does the necessary statistics and generates a box plot. It is configured using INI-style files.

File (4.77 KiB)

Vary Parameters in .ini-Files

It is quite easy to write a program in any language which is configurable via .ini-files like this:

param1 = 1
param2 = true
param3 = 1

If you now want to test this program for all combinations of parameters, you run into a problem: Where do you implement the loop over all parameter combinations? The script File (8.50 KiB) is an elegant way out: You write one more .ini-file that tells it what to vary where and it will run the whole experiment for you. The documentation is embedded, you can also read it online.

Convert Phone Numbers to Words

Words are easier to remember than numbers! File (1.04 KiB) takes a phone number and a dictionary as its input and tries to find words that you can enter on your phone “instead” of the number.

Deutsch -> Sächsisch Konvertierer

 1 #!/usr/bin/perl -w
 3 # #!/usr/bin/perl -wnp
 6 while(<DATA>){
 7     print join ' ', map {
 8         ($pre,$_,$post) = m/^([^\w]*)(\w.*?\w)([^\w].*)?$/;
 9         $pre  ||= "";
10         $post ||= "";
11         s/ebe/eh/ig;
12         s/st/schd/ig;
13         s/sp/schb/ig;
15         # phonetics
16         s/t/d/ig;
17         s/ck/gg/ig;
18         s/k/g/ig;
19         s/p/b/ig;
20         s/ei/ee/ig;
21         s/ö/ee/ig;
22         s/er$/or/ig;
23         s/ig/sch/ig;
24         s/au/u/ig;
25         s/nd$/n/ig unless /Mund/i;
26         s/st$/s/ig;
27         s/en$/n/ig;
28         s/a/o/ig;
29         $pre . $_ . $post
30     } split /\s+/;
32 }
34 __DATA__
36 angesichts der aktuellen Ereignisse finde ich es nicht satirisch, sonders
37 vielmehr geschmacklos ein Amokformular zum Download anzubieten. Es gibt so
38 viele TRittbrettfahrer, die nur auf so etwas warten. Ich wurde auf den Link in
39 einer Internetplattform, in der sich überwiegend Schüler ab ca 11 Jahren
40 bewegen aufmerksam. Ich appeliere an Ihre Verantwortung gegenüber der jungen
41 Generation dieses Dokument sofort zu entfernen. Das hat leider mit Satire
42 nichts mehr zu tun! Mehr Sensibilität der Medien würde ich mir wenigstens in
43 der Weihnachtszeit wünschen.

Webgen Syntax Highlighter Plugin Using Vim Editor

This site is generated using webgen. Webgen has limited support for syntax highlighting, as it uses the ruby coderay library. Coderay supports only a few languages. The following plugin for webgen uses the vim editor to highlight code in basically any language. It caches its output and only runs vim if something changed.

Install: Usage:
  • ...