A picture of a star

Computer Notes

This is a page on which I place notes about how to do miscellaneous things, as an aide memoire.

Making Pretty Graphs with Gnuplot

apt-get install pyxplot. Alternatively...

  1. In gnuplot, do "set term post enh 'Times' 20"
  2. "set nokey"
  3. For LaTeXed labels, do "set xlabel 'xlabel'" etc.
  4. Plot the file then run 'frob_axes.pl graph.eps newgraph.eps xlabel latex_commands...'
  5. Open the resulting postscript in vim. Search for xlabel and move it a bit so that it's correctly aligned, ditto for ylabel.
  6. Search for "gnulinewidth" and change the 5 to a 10.
  7. Save the file, wondering why you didn't use a better plotting package in the first place...

Some useful gnu^WPyXPlot commands for stars output

q vs P
plot 'plot.1' u (($44-$6)/$6):45 w l
q vs R2/a
plot 'plot.2' u ($6/($44-$6)):(exp($3/.43429-(.666*log($45)+0.3333*log($44)+1.4322546))) w l

Extracting single files from a tar archive

tar xv[z]f <archive> <filename>

Making a2ps print wide text "sensibly"

a2ps -1 --landscape --font-size=10 -o postscript.ps widefile.txt
(Why is a2ps so awful?)

ftnchek

This useful program needs a little bit of massaging to make it happy:

ftnchek -columns=999 -pretty=no-long-line FILES

will stop it worrying about long lines. You may wish to add -usage=no-var-unused if you don't care about unused variables and -truncation=no-promotion to avoid lots of errors regarding promotion of variables, though you should probably fix these errors instead. -usage=no-var-uninitialized is also good if you use automatic variable initialization. Good for the Eggleton code is:

ftnchek -columns=999 -pretty=no-long-line -usage=no-var-uninitialized -usage=no-var-unused FILES

Be warned that ftnchek will tend to produce lots of output unless your code is really well written!

Chunks of files

sed 'a,b!d' filename
gets you lines a to b of the file (fanf2)
awk '(NR%10==0)' filename
gets you every tenth line of a file.

Talking to apache via telnet

GET / HTTP/1.1
User-Agent: telnet
Host: whatever
The lines need to be in the right order, it appears, or it doesn't work.

gdb

gdb is annoying, but can be useful. Note that to flush output from a fortran programme to file 'call fflush(0)' will help (thanks Ian!).

valgrind

You want valgrind --db-attach=yes .

mencoder

The following line (courtesy of Nick Law) seems to produce useful output:
mencoder mf://*.jpg -mf fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg2video:vrc_buf_size=18350:vrc_maxrate=20000:vbitrate=15000:keyint=15 -oac copy -o output.avi
Mmmm, nice short command line there...

Meanwhile to transcode videos using avconv the following seems to work OK:

avconv -i IN.MOV -qscale 4  -b 640k -maxrate 4000k -bufsize 1835k  OUT.avi

vim

The following bits of random stuff are useful:

postscript

There's lots of useful postscript stuff out there; this is a very small selection as and when it comes to me

FORTRAN arrays

If you loop over an array according to

((a(i,j),i=1,20),j=1,20)

svn

To move a working copy between repositories:

svn switch --relocate $OLDURL $NEWURL

(Thanks to malc)

Sequences of numbers with bash

$ echo {1..20}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Notes on the Eggleton Code

Home - Astronomy - Photos - Computer notes - Weblog

This website was produced by Ross Church and no longer contains a joke in the footer.