Sometimes it's all about the aesthetics.

Showing posts with label Duh. Show all posts
Showing posts with label Duh. Show all posts

8/14/2009

abs() in awk command

It has been very annoying that there is no intrinsic absolute function in awk, but it's still easy to do it by ourself:

$ paste tmp1/energy.txt tmp2/energy.txt tmp3/energy.txt tmp4/energy.txt \
? | awk 'function abs(x){return (((x < 0.0) ? -x : x) + 0.0)}\
? {printf "%s %25.12f %25.12f %25.12f %25.12f\n", $1,\
? abs($2-$2),abs($4-$2),abs($6-$2),abs($8-$2)}'

12/16/2008

I am not even a 50% geek?!

Very disappointing.

I am 35% Geek.
Geek? Yes, but at least I got social skills.
You probably work in computers, or a history deptartment at a college. You never really fit in with the "normal" crowd. But you have friends, and this is a good thing.

11/17/2008

Tiger's bonjour, tcp wrapper, ipv6 oh mine.

After the port 22 of my iMac got flooding of connection attempts (inside a private network, but redirecting all incoming traffic to the router to this machine..), I decided to use tcpwrapper for sshd on my leopard laptop. It's easy, just add this to /etc/hosts.deny

sshd : ALL EXCEPT LOCAL
and add this to /etc/hosts.allow
sshd : 10.0.1.0/255.255.255.0
Unfortunately I didn't know there is a catch: my tiger machine cannot connect through SSH to my leopard laptop. I wasn't sure what's going on at first. This problem bothered me before and I gave it up. This time I launched the console program and started to read the error message.
11/17/08  11/17, 5:23:44 PM sshd[3041] warning: /etc/hosts.allow, line 1: host name/address mismatch: fe80::205:xxxx:fed0:xxxx != powerbook.local
11/17/08  11/17, 5:23:44 PM sshd[3041] refused connect from fe80::205:xxxx:fed0:xxxx
The laptop is saying that the hostname of the 10.4 machine does not match with a ipv6 style IP address. Okay, now I know what to do. I can just use ssh -4 to specify ipv4 connection and the problem is solved. I don't want to know why 10.4 machine is using ipv6 as primary ip for bonjour due to my laziness. At least I don't see that problem on leopard. Now I can do this without remembering my ip inside the AirPort network
rsync -e 'ssh -4 -x' -avx --delete --exclude '*.spotlightIndex' ~/Documents/Papers/ powerbook.local:Documents/Papers/