January 11th, 2008
Last night I accidentally came across something really funny. Did you know that there’s a /bin/true that just does nothing, successfully?
This is a really amazing mapage:
NAME
true - do nothing, successfully
SYNOPSIS
true [ignored command line arguments]
true OPTION
DESCRIPTION
Exit with a status code indicating success.
These option names may not be abbreviated.
--help display this help and exit
--version
output version information and exit
AUTHOR
Written by Jim Meyering.
I think you can do things like that with “true”:
while /bin/true; do sleep 5; kill ...; done
At least the most bizzare thing about it is that the version is 5.96.
January 11th, 2008
I’ve always been annoyed by not having clearly marked errors (besides the word “error”) when using gcc/g++ from shell.
Now a simple python script helps me to notice every appearing error out of lots of unimportant lines of stuff (warnings e.g.).
highlight.py:
1
2
3
4
5
6
7
| import sys
while 1:
input = sys.stdin.readline()
if len(input.lower().split("error")) > 1:
print chr(27) + '[91;1m' + input.strip() + chr(27) + '[0;0m'
else:
print input.strip() |
Additionally I created a function and an alias in .bashrc which determines the behavior of the shell:
alias gcc_real=$(which gcc)
alias gcc='gcc_highlight'
function gcc_highlight()
{
gcc_real $@ 2>&1 | python ~/highlight.py
}
alias gpp_real=$(which g++)
#...and the same for g++
}
The usage of gcc_real is very important, otherwise gcc would call gcc and so on…perfect recursion. 
gcc errors are not reported over stdout but over stderr which means i had to use 2>&1 to forward them.
December 22nd, 2007
Didn’t you ever wanted to know where the corious server from which you’re currently downloading is located?
I did! Here’s the solution:
geoiplookup - look up country using IP Address or hostname
The .deb package for installing is called geoip-bin
The output is not very detailed it just prints out the country, but if you download this .gz and extract it to /usr/share/GeoIP you can also find out what city/town.
geoiplookup amazon.de
GeoIP Country Edition: IE, Ireland
GeoIP City Edition, Rev 1: IE, 07, Dublin, (null), 53.333099, -6.248900, 0, 0
GeoIP City Edition, Rev 0: IE, 07, Dublin, (null), 53.333099, -6.248900