notes, hacks, tweaks, config files, etc.

These are mostly just notes for myself, but I've made them publicly available in case someone might find them useful.

PDL cumuintover function | PDF makefile | .muttrc file | what programs are listening to open ports

LPD printer setup in CUPS | Convert PS to PNG | Color PS to Gray | apt-get MMap errors

apt-get sources.list file | Turning off emacs bars | ssh config | exim4 config

cumuintover function for PDL

I've implemented a "cumuintover" function. Analogously to "cumusumover" and "cumuprodover" it returns a piddle with the same dimensions as the input containing the integral over the first dimension.

Note that it will crash if you feed it a piddle with a first dimension of less than 6. If it's of use to anyone, I could modify it to behave like intover and work for dims < 6.

Here is the code and demo of the code using inline, along with the pp_def.

Running the demo should give:

$ perl
     x   |    num  |    ana  |   rel err
       0         0         0       nan  
       1      2.13      2.13  8.43e-08  
       2      14.1      14.1  3.68e-08  
       3      56.5      56.5  1.91e-08  
       4       162       162  1.23e-08  
       5       377       377  9.35e-09  
       6       758       758  7.95e-09  
       7  1.38e+03  1.38e+03  7.37e-09  
       8  2.33e+03  2.33e+03   7.3e-09  
       9   3.7e+03   3.7e+03  7.62e-09  
      10  5.63e+03  5.63e+03   8.3e-09  

Here's the pp_def:

# from equation 4.1.14, Press et al. 2nd Ed chapter 4.1
       Pars => 'f(n); int+ [o]g(n);',
       Code => '
int i;
int ns = $SIZE(n);
$GENERIC(g) tmp = 0;
threadloop %{
tmp = (3.0/8.0) * $f(n=>0) +
      (7.0/6.0) * $f(n=>1) +
      (23.0/24.0) * $f(n=>2);
for (i=5;ii) = tmp +
                             (23./24.) * $f(n=>i-2) + 
                             (7./6.)   * $f(n=>i-1) + 
                             (3./8.)   * $f(n=>i); 
                     tmp += $f(n=>i-2);
$g(n=>0) = 0;
$g(n=>1) = ($f(n=>0) + $f(n=>1))/2.0;
$g(n=>2) = ($f(n=>0) + 4. * $f(n=>1) + $f(n=>2) ) / 3.0;
$g(n=>3) = (3/8) * ($f(n=>0) + $f(n=>3) + 3. * ( $f(n=>1) + $f(n=>2) ) );
$g(n=>4) = (1./45.) * (  14. * ( $f(n=>0) + $f(n=>4) )
                    + 64. * ( $f(n=>1) + $f(n=>3) )
                    + 24. * $f(n=>2) 

Makefile for automating the generation of PDF or postscript files from latex source

If you have a latex file called name.tex you would run the command make -r name.pdf. See the comments for a way to include bibtex processing.

.muttrc file config file for mutt

You'll need to edit it for your own mail server configuration. Look for lines with the comment "replace".

Finding out what programs are listening to open ports

nmap, lsof, and netstat, all fairly standard linux utilities, can help you find out what open ports you have on your machine and what programs are listening to them.

nmap localhost reveals what ports are listening on the local machine.

lsof -i as root (or sudo lsof -i) reveals what programs are listening to what ports.

netstat -lp --inet as root (or sudo netstat -lp --inet) also reveals what programs are listening to what ports.

Setting up LPD printers with CUPS in Debian GNU/Linux

based on a Solaris printers.conf file

I looked at a file called /etc/printers.conf on a Sun machine that was already set up to print on our network. It had an entry that looked like this (of course was an actual host name):


Physical inspection reveals that the printer is a Lexmark T420, but I didn't have a driver handy for that, so I decided to try the "HP 4100 PS" driver that I was already using for another printer. I set up an "LPD/LPR" printer with "Device URI: lpd://", selecting "Make: HP" and "Model: HP LaserJet 4100 PS". Miraculously enough, it seem to work (presumably because they both use postscript). I even got it to print double sided by setting the "Duplex: flip on long edges" and "Duplex unit: installed" options in CUPS.

Batch Conversion of postscript files to PNG images

I use pstoimg, often with the -flip option:

pstoimg -flip cw filenames*.ps

Batch conversion of color postscript to gray-scale

This script works well for me, and allows conversion to either gray-scale or straight black-and-white. I wrote a another script as a quick-and-dirty solution for converting a whole batch of files.

For example:

mkdir bw_figs
perl bw_figs *.ps

Preventing MMap errors using Debian package management

Running synaptic package manager on my Ubuntu ("Breezy-Badger") system or apt-get I was getting "MMap" errors after I added a bunch of extra software repositories to my /etc/apt/sources.list file:
roban@lithops:~$ sudo apt-get update
Get:1 breezy-updates Release.gpg [189B]
Get:2 stable Release.gpg [189B]
E: Dynamic MMap ran out of room
E: Error occurred while processing synaesthesia (NewVersion1)
E: Problem with MergeList /var/lib/apt/lists/
E: The package lists or status file could not be parsed or opened.
Found the
solution was to create a file /etc/apt/apt.conf.d/00Cache with the following contents:
APT::Cache-Limit "141943904";
This could probably be a much smaller number, but I'm not having any problems with it, yet.
In one line:
echo 'APT::Cache-Limit "141943904";' > /etc/apt/apt.conf.d/00Cache
or (note that this uses a subshell to make redirection work with sudo, a trick taken from the sudo man page)
sudo sh -c "echo 'APT::Cache-Limit "141943904";' > /etc/apt/apt.conf.d/00Cache"

apt-get sources.list file

Turning off emacs toolbar, menubar, and scrollbar

I used to have some lines in my .emacs file like this:
(menu-bar-mode 0)
(tool-bar-mode 0)
(set-scroll-bar-mode nil)
But that was a problem because I couldn't properly set the emacs frame (X window) geometry in my .Xresources file because the frame shrinks when the bars are turned off after emacs has started up rather than giving the extra space to the text window. A better solution is to specify that you don't want these bars in your .Xresources file:
emacs.geometry: 80x53
emacs.menuBar: off
emacs.verticalScrollBars: off
emacs.toolBar: 0
Works like a charm. Remember, after editing your .Xresources file, run xrdb -merge ~/.Xresources to see the effects of your changes.

ssh config file

My customized ssh config file just has a couple settings changed from the defaults: forward X connections and turn off hashing of the known_hosts file. Turning off hashing allows the bash auto-completion engine to tab-complete host names for the ssh command. This file is ~/.ssh/config on my computer.

exim4 config

After installing exim4 (or running dpkg-reconfigure exim4-config) I still needed to get authentication working for our SMTP server.

To use an alternate port when you want exim4 to deliver mail to a smarthost, add the line port = 587 (where 587 is replace with whatever port you want to use) to the remote_smtp_smarthost section of your configuration file (in debian /etc/exim4/exim4.conf.template).

For our system I also had to add the following lines to /etc/exim4/passwd.client

Then I ran update-exim4.conf, restarted exim4, and sending mail worked from mutt.

Roban Hultman Kramer