Monday, September 22, 2014

Grep with Multiple Expressions

Occasionally, you want to find all the lines in a file which have either 'eng', or 'net', or 'ide' in them.

You think "I know, I'll use regular expressions".

Now, you have three problems. The one you weren't expecting is grep's weird syntax for regular expressions.

This subject is both deep and boring. Suffice it to say that:

grep 'eng\|net\|ide'

is an answer

grep -E 'eng|net|ide'

and

ack 'eng|net|ide'

is an answer.

If you really want to know the details, look up 'basic regular expressions', 'extended regular expressions', and 'perl-compatible regular expressions'.



Monday, August 25, 2014

Make Caps Lock Into Control

grrr: After using this for a while, I noticed that xmodmap settings don't get restored after suspend/hibernate. This is annoying, but once you figure out what's going on it's easy enough to run xmodmaprc ~/.xmodmaprc manually. So I'm still using it, it's just not as cool as I thought at first. I imagine there's some way to hook this into the resume scripts....


There's no use at all for the Caps Lock key, once you are old enough NOT TO THINK THIS SORT OF THING IS CLEVER, and in fact having it usually causes problems.

You can make it into another, much more conveniently positioned Control key using an ~/.xmodmaprc file, which should contain the lines:

clear Lock
keycode 0x42 = Control_L
add Control = Control_L



That's it. xmodmap will execute the commands when the X server starts.

Either log out and log back in again, or use:

$ xmodmaprc ~/.xmodmaprc

to run that file explicitly, and from now on, any application running under X will see your Caps Lock key as a Control key instead.

This makes emacs enormously more pleasant to use.

Thursday, August 21, 2014

Emacs 24.3.1 and Octave 3.8.1 Inferior Octave Hangs


With GNU Emacs 24.3.1 and GNU Octave, version 3.8.1 an attempt to execute a line of octave hangs, with the inferior octave buffer displaying the welcome text.

This is because they disagree on what the prompt should be:
Creating a ~/.octaverc with the line PS1(">> ") should fix this:

$ cat >~/.octaverc
PS1(">> ")

Monday, June 9, 2014

BBC iplayer / get-iplayer


Suppose someone sends you a link to an iplayer program:

http://www.bbc.co.uk/iplayer/episode/p018dvyg/horizon-19811982-9-the-pleasure-of-finding-things-out

And you follow it and find some insanely overcomplicated flash-filth at the other end.

All is not lost.

sudo apt-get install get-iplayer

get-iplayer --get http://www.bbc.co.uk/iplayer/episode/p018dvyg/horizon-19811982-9-the-pleasure-of-finding-things-out

and you have a nice copy in a usable format, which you can play with mplayer, as a man should.

mplayer Horizon_-_1981-1982_9._The_Pleasure_of_Finding_Things_Out_p018dvyg_default.mp4

Sunday, January 19, 2014

Like top, but for Networks

Every so often I ask myself 'what is like top, but for networks'.

And after ages experimenting, I always end up using one of:

sudo nethogs wlan0
 

sudo iftop -i wlan0

sudo iptraf