Skip to main content

Mit Windows waer das nicht passiert

Uh, Solaris, you stubborn beast:

$ date +%s
No, implementing yet another switch to display a timestamp in seconds since epoch like the GNU or BSD tools do, would be too easy, now would it? Someone on the net even suggested this hack, which is kinda cool, but it still hurts my eyes so badly:
$ truss date 2>&1 | awk '/^time\(\)/ {print $3}'
Maybe I should just go with:
$ perl -e "print time"
....but having this one in date(1) would be nice too. Really.

Update: Malte wants to share his strace solution as well:
$ strace date 2>&1 | awk '/^clock_gettime/ {print $2}' | sed 's/[\{,]//g'

Update #2:
$ strace -ttt /bin/true 2>&1 | cut -d\. -f1 | head -1

stealin' cookies

alice$ echo $DISPLAY

alice$ xhost +
access control disabled, clients can connect from any host

alice$ su - bob
bob$ DISPLAY=localhost:11.0 xclock
X11 connection rejected because of wrong authentication.
The reason for that is that X11 is using a magic cookie to authenticate against the specified X server. And we want that sweet bastard:
bob$ sudo cp ~alice/.Xauthority .
bob$ DISPLAY=localhost:11.0 xclock
Yes, it's that easy. But seem to forget things like this too often - now it's here, forever. And ever ;)

lighttpd & symlinks

My Lighttpd/FGCI/PHP installation sometimes has difficulties with php scripts which are really symlinks. Now, to be honest I have not fully debugged this issue yet, but sparse error messages like "No input file specified" and blaming PHP are not really helpful when no workaround is in sight. Some said that setting broken-scriptfilename would help, which was been introduced in 2005, but with lighttpd-1.5, the whole fast-cgi setup has been changed quite a bit and this option is not applicable any more. To be fair, there's even a FAQ entry for this particular error message, but it was not as straightforward as it looked like:

>  You forgot to add '''cgi.fix_pathinfo=1 to your php.ini''' file
....tried that, with no effect.
> If open_basedir is set, make sure the requested file 
is below one of the directories which is specified there.
 > If you are running PHP with different permissions than lighttpd
 > Make sure you did not set doc_root or userdir in php.ini, or if you have 
set it, make sure it has the correct value
....there are different vhosts here, each having a different server.document-root set, but only one php.ini where I could set doc_root. However, php.ini/user_dir value was unset - when I set it to the same value as userdir.path in lighttpd, at least the symlinks below the ~user directories were working again! Of course, one could have different values for userdir.path (or is this a global option?), but I guess having a single userdir.path value is much more feasible than having just one server.document-root set.


$ TZ=GMT date
Tue Oct 28 18:07:16 GMT 2008
$ TZ=MET date
Tue Oct 28 19:07:17 MET 2008
$ TZ=MEST date
Tue Oct 28 20:07:18 MEST 2008
$ TZ=PST8PDT date
Tue Oct 28 11:07:19 PDT 2008
Soon we'll have a time difference of 9 hours again, although it does not make a difference from a practical pov and I wish someone would stop this madness...

Update: yet another story (in German) covering this nonsense....

name-{san,sama,kun,chan} - learn something new everyday

I always wondered why Japanese people sometimes add strange suffixes to names or surnames. And I wonder why I had to go to Yahoo! to find the (hopefully correct) answer:

Keep in mind that a Japanese speaker may not be entirely sure which is your given
name and which is your surname. -san can be attached to either. You should use the
Japanese person's surname unless you come to consider that person a friend. -san
doesn't really "mean" anything. It is a suffix attached to a person's name to
indicate respect, roughly like "Mr./Mrs/Miss" -- but not quite. There are other
suffixes for  other occasions and people: -sama for very important people, -kun 
for close male friends, -chan for kids and people you want to be very familiar with.

n rules to sort them all

Ah, this is something I always wanted to have for my MUA of choice, but never dared to ask: per folder sorting rules. It's as easy as:

  > Yes, press M S R O and configure this, or if you have enabled
  > [X] Enable Take Rules
  > then simply press "T" in the folder you want to use and then from the menu
  > in the bottom, select "O".
...and how intuitive ;-)

How to disable the Spotlight icon

After disabling Spotlight in MacOSX, the Spotlight icon in the menu bar was still there, taking up precious space on my 12" PowerBook G4. Here's how to disable the icon as well:

  sudo chmod 0 /System/Library/CoreServices/Search.bundle/
  pkill -9 SystemUIServer
And, while we're at it - again the procedure to disable the Dashboard:
  defaults write mcx-disabled -boolean YES
Enable with "NO" again and start "Dashboard" from /Applications.

POSIX me harder

POSIX specifies that `-exec` can be ended by a semicolon or a plus sign, the latter taking the arguments as sets (up to ARG_MAX). That said, I wonder why many half-current implementations (RHEL 4; MacOS 10.4) of find(1) still don't understand the plus sign. When working with a lot of files the difference in speed is quite visible:

 $ find /dir -type f | wc -l
 $ /usr/bin/time -v find /dir -type f -exec ls {} + > /dev/null
 User time (seconds): 0.05
 System time (seconds): 0.02
 Percent of CPU this job got: 98%
 Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.07
 Minor (reclaiming a frame) page faults: 781
 Voluntary context switches: 3
 Involuntary context switches: 11

 $ /usr/bin/time -v find /dir -type f -exec ls '{}' \; > /dev/null
 User time (seconds): 1.69
 System time (seconds): 2.76
 Percent of CPU this job got: 49%
 Elapsed (wall clock) time (h:mm:ss or m:ss): 0:09.01
 Minor (reclaiming a frame) page faults: 938927
 Voluntary context switches: 3561
 Involuntary context switches: 4779