Recently in Mac Category

Nothing more than a rant....
It's not that tough - when using most english locales, we sort case insensitively. a==A, B==B and so on. Pragmatically, the only reason for picking a locale other than UTF-8.generic is because I would really, really like these rules obeyed.
I am sick to death of having to work around stupidity.
I'm just complaining as I look at the output from ls and it's pretty much a case sensitive sort. I'm sure that accents are sorted correctly in EN_ie - after all á is the same as a, but apparently it's different to A.
Sorting it difficult... the rules are so complicated... stop complaining! you're able to perform at least 600 million operations per second, and a table lookup for a case insensitive sort is probably going to cost 20.
Bear in mind that the number above was a quick back of the envelope number of an iPhone. I'm sure a real computer will be able to do something a little better...

Update:

Looks like it's not Linux, it's only Leopard that doesn't understand EN_ie collation. Oh well, that's life I suppose…

XcodeScreenSnapz001 - nullity null Apparently I forgot to plug out my null before quitting the application. That's a shame as I thought I had two or three nulls floating around

signal versus sigaction

| No Comments | No TrackBacks
the use of the
signal(int signum, void (*handler)(int))
is a smidgin dangerous on various operating systems. Under Solaris, for example once the signal has been delivered to the process the signal handler is reset, so a typical piece of code that wants to reuse the signal handler repeatedly will typically set the signal handler again when receiving the signal. This leads to a minor race condition where upon receipt of the signal and the re-setting of the handler the process receives another copy of the same signal. Some of these signals cause Bad things to happen - such as the stopping of the process (SIGTSTP for example). Under Linux it keeps the signal handler in place, so you have no fear of the event triggering an unwanted event.
The manual page for
signal
under Linux makes it clear that the call is deprecated in favour of the much more functional
sigaction(int sig, const struct sigaction *restrict act, struct sigaction *restrict oact)
call, which keeps signal handlers in place when you don't pass the SA_RESETHAND parameter as part of the sa_flags parameter of the sigaction structure. So you get to explicitly choose to accept a signal once, and then have the system deal with it in the default manner afterwards.
Signals, are of course a real pain in the ass when dealing with sub-processes. For example the use of ptrace to perform profiling works well until you fork. If another SIGPROF signal arrives before you can create your signal handler then the child process is terminated as that's the default behaviour in that situation.
Under Solaris (and Leopard) you can make use of dtrace to perform profiling on a set of processes without needing to deal with vagaries of signal handling, making this a non-issue. For those of you stuck in LD_PRELOAD land, probably the only thing that can be done is to set the signal disposition to be ignored before execing the new process. you have a small window where the profiling is missing, but the overall increased stability of the application is improved by preventing it from accidentally being terminated due to a profiling signal being received too soon. I know the accuracy nuts would hate that, but it's part of the price of dealing with standards.
apparently it could have something to do with the theme, but this morning I noticed that the GrowlHelperApp was using about 200MB of wired down memory.
Restarting it seems to have restored it to a reasonable size, but I shall set up a dtrace script to keep an eye on it.
mobileme calendar It's a bit funny to mention this, but the mobileme calendar badge has the correct date. Just like the calendar date on the macosx desktop and the iphone/touch (which took a while to get right.
Yes, I know; completely trivial
I don't want to keep manually syncing my address book on Vodafone with that of my mac, so I use this script to pull out the phone numbers of people when I want to send them a text message using webtext (or my webtext script).
#!/bin/sh

search_for=name
return_val=phone

args=$(getopt s:r: $*)

set -- $args

while :; do
    case $1 in
        -s) search_for=$2; shift;;
        -r) return_val=$2; shift;;
        --) shift; break;;
    esac
    shift
done

if [ $# -lt 1 ]; then
    echo 1>&2 "usage: $(basename $0) -s <search> -r <return> YOUR_SEARCH"
    exit 127
fi

search=
for i in $@; do
    if [[ -z $search ]]; then
        search="($search_for contains \"$i\")"
    else
        search="$search and ($search_for contains \"$i\")"
    fi
done

scriptcode="tell app \"Address Book\" to get (value of $return_val) of every person where $search"

osascript -s "s" -e "$scriptcode"

exit 0


You can get it Here.

More features...

| 1 Comment | No TrackBacks
Address Book Sync Options It looks like we have a bunch more sync options for the address book now. I don't believe it supported Exchange or Google prior to 10.5.4, now it does. Let the insanity of address book syncing continue.
iTunesScreenSnapz001.png It's kind of noticeable. Respect the grid!
I wonder what it looks like on windows...
I would not recommend using spaces on a multi-monitor setup. It's just a bit too painful to use. Things just disappear into the pit of another space.
It works well on a single-monitor setup though.
I was concerned that it wasn't working properly when I was trying a ::tick-100 /execname == "iTunes"/ { @[ustack()] = count() }, which is kind of useless, and all I received was a bunch of errors involving invalid addresses.
However, it seems to be working...
himitsu:/Library/Extensions# gdb --pid=$(ps -fe | grep '[i]Tunes' | grep -v Helper | awk '{print $2}')
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".
/Library/Extensions/15971: No such file or directory.
Attaching to process 15971.
zsh: segmentation fault  gdb --pid=15971
himitsu:/Library/Extensions# kextload pt_deny_attach.kext                                                
kextload: pt_deny_attach.kext loaded successfully
himitsu:/Library/Extensions# gdb --pid=$(ps -fe | grep '[i]Tunes' | grep -v Helper | awk '{print $2}')
GNU gdb 6.3.50-20050815 (Apple version gdb-960) (Sun May 18 18:38:33 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".
/Library/Extensions/16048: No such file or directory.
Attaching to process 16048.
Reading symbols for shared libraries . done
Reading symbols for shared libraries .................................................................................................................................................... done
0x943114a6 in mach_msg_trap ()
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from process 16048 thread 0x20b.
himitsu:/Library/Extensions# 
It's great. simply prettier and a lot more usable than Firefox 2. The awesome bar (the address bar) kicks ass. Much easier to use than the previous one. Bookmark management has been improved. The look and feel is nicer. I even 'kind of' prefer the subtle dialog box improvement which turns up at the top of the form, which is like a wide series of websites that perform the same thing themselves.
This definitely has replaced my web browsers in Windows and Linux. There's a very high chance that it will replace Safari on the Mac. The only niggle I have is that it doesn't store your passwords in the Mac keychain, which I still feel is the better place to have them.
Damn the electric fence...

gravatar URIs

| No Comments | No TrackBacks
Short and simple: http://en.gravatar.com/avatar/<md5 hash of email address>?.
e.g. echo -e 'bob@email.com' | md5sum gives: c961431faea38ed65bfd982cf2e31bd0. Optional add-ons are size (s=<Number of pixels>), content rating (r=<g, pg, r, or x>), and default (d=<escape encoded URI of an image or one of identicon, monsterid or wavatar>).
great place to do something akin to the 'imitate a lotus notes password entry trick'.
I'm just wondering why there's this aversion to flash from Apple. Is it that developers of flash applications depend on mouseover events that simply are not suitable for a non-mouse environment?
Possibly? Probably? I don't know.
Lazy lazy leopard. All the collate definitions seem to point to ascii based sorting in english locales.
himitsu:/usr/share/locale% ls -l en_*/LC_COLLATE
lrwxr-xr-x  1 root  wheel  29 21 Feb 16:19 en_AU.ISO8859-1/LC_COLLATE@ -> ../la_LN.ISO8859-1/LC_COLLATE
lrwxr-xr-x  1 root  wheel  30 21 Feb 16:19 en_AU.ISO8859-15/LC_COLLATE@ -> ../la_LN.ISO8859-15/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_AU.US-ASCII/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_AU.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_AU/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  29 21 Feb 16:19 en_CA.ISO8859-1/LC_COLLATE@ -> ../la_LN.ISO8859-1/LC_COLLATE
lrwxr-xr-x  1 root  wheel  30 21 Feb 16:19 en_CA.ISO8859-15/LC_COLLATE@ -> ../la_LN.ISO8859-15/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_CA.US-ASCII/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_CA.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_CA/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  29 21 Feb 16:19 en_GB.ISO8859-1/LC_COLLATE@ -> ../la_LN.ISO8859-1/LC_COLLATE
lrwxr-xr-x  1 root  wheel  30 21 Feb 16:19 en_GB.ISO8859-15/LC_COLLATE@ -> ../la_LN.ISO8859-15/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_GB.US-ASCII/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_GB.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_GB/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_IE.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_IE/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  29 21 Feb 16:19 en_NZ.ISO8859-1/LC_COLLATE@ -> ../la_LN.ISO8859-1/LC_COLLATE
lrwxr-xr-x  1 root  wheel  30 21 Feb 16:19 en_NZ.ISO8859-15/LC_COLLATE@ -> ../la_LN.ISO8859-15/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_NZ.US-ASCII/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_NZ.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_NZ/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  29 21 Feb 16:19 en_US.ISO8859-1/LC_COLLATE@ -> ../la_LN.ISO8859-1/LC_COLLATE
lrwxr-xr-x  1 root  wheel  30 21 Feb 16:19 en_US.ISO8859-15/LC_COLLATE@ -> ../la_LN.ISO8859-15/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_US.US-ASCII/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_US.UTF-8/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
lrwxr-xr-x  1 root  wheel  28 21 Feb 16:19 en_US/LC_COLLATE@ -> ../la_LN.US-ASCII/LC_COLLATE
The 'sorting rule' for irish is:
--
-- Irish Gaelic alphabet:
--
-- Aa (Áá), Bb, Cc, Dd, Ee (Éé), Ff, 
-- Gg, Hh, Ii (Íí), Jj, [Kk], Ll, Mm, 
-- Nn, Oo (Óó), Pp, Qq, Rr, Ss, Tt, 
-- Uu (Úú), Vv, Ww, Xx, Yy, Zz 
--
i.e. Case insensitive, and accented characters after non-accented characters (case insensitive). Surname sorting is even more fun, but I would not expect ls to do that. Finder sorts correctly in this case, but that seems to be due to the fact that it uses the Unicode Collation Algorithm. Shame, I would have preferred both to use the same mechanism.
Well linux and solaris get it correct, but it looks like the little old mac can't sort things lexicographically (even when it claims in the manpage that it does).
On Linux/Solaris:
~/x% locale
LANG=en_IE.UTF-8
LC_CTYPE="en_IE.UTF-8"
LC_NUMERIC="en_IE.UTF-8"
LC_TIME="en_IE.UTF-8"
LC_COLLATE="en_IE.UTF-8"
LC_MONETARY="en_IE.UTF-8"
LC_MESSAGES="en_IE.UTF-8"
LC_PAPER="en_IE.UTF-8"
LC_NAME="en_IE.UTF-8"
LC_ADDRESS="en_IE.UTF-8"
LC_TELEPHONE="en_IE.UTF-8"
LC_MEASUREMENT="en_IE.UTF-8"
LC_IDENTIFICATION="en_IE.UTF-8"
LC_ALL=
~/x% ls
a  B  c
On the Mac:
himitsu:~/x% locale
LANG="en_IE.UTF-8"
LC_COLLATE="C"
LC_CTYPE="en_IE.UTF-8"
LC_MESSAGES="en_IE.UTF-8"
LC_MONETARY="en_IE.UTF-8"
LC_NUMERIC="en_IE.UTF-8"
LC_TIME="en_IE.UTF-8"
LC_ALL=
himitsu:~/x% ls
B  a  c
According to the spec:
The following environment variables shall affect the execution of ls ...
LC_COLLATE
Determine the locale for character collation information in determining the pathname collation sequence.
Sad little mac does not sort by the locale's character collation specification (case insensitive, in case you missed it).

open -h(uuuh?)

| No Comments | No TrackBacks
On windows we have start for launching documents and applications. On gnome we have gnome-open which opens documents and applications. On the mac we have the 'open' command. Open -a launches the specified application (based on the app paths). Open on it's own launches a document with the registered preferred application. Then there's 'open -h'.
% open -h unistd.h
unistd.h?
[0]	cancel
[1]	all

[2]	/System/Library/Frameworks/Kernel.framework/Headers/libsa/unistd.h
[3]	/System/Library/Frameworks/Kernel.framework/Headers/sys/unistd.h
[4]	/usr/include/sys/unistd.h
[5]	/usr/include/unistd.h

Which header(s) for "unistd.h"? 5
It opens up header files. I mean WTF?
Having broken my iPod, I decided to change the root password from the default of 'alpine' to something more sensible. I logged in and changed the root password using the passwd command. More fool me, apparently as the springboard kept restarting on me.
I still had ssh access (and root login worked). I made sure that the user/group listings were set to 0 for the mobile user in both the passwd and master.passwd files. Then I made sure that all the entries in passwd had an asterisk for the password and the entry in the master.passwd file contained the output from perl -e 'print crypt("yournewpassword", "/s"), "\n"'. All is good again! I think...
Update: later, things were still not working properly so I restored and just manually put in the entry for the account rather than trying to convince it to work. Oh well, practice makes imperfect I suppose.
Leopard's wireless access is a bit of a problem. This morning it decided to connect to the one base station in the office that is transmitting it's ssid (down stairs, in the lab). There are two other base stations in the office, each of which does not transmit their ssid (one about 5 feet from me) but does it pick up the base station that's the closest? nooo, it picks the one that transmits it's ssid.
There's no way to force Leopard to bind to a particular base station is there? I think I can do this with windows, and I know I can do it with the N95. The options for the Mac are quite limited. I feel like I'm trapped in a particularly well implemented Gnome environment :)

Several GSODs later...

| No Comments | No TrackBacks
Well, the mac doesn't get BSODs it gets a slightly differently colored grey screen of death. Thankfully I had saved before yanking out the plug for the external monitor. It greyscreened on me with the multi-lingual press the power button for a few seconds message on-screen.
I mean really guys, this is grade-A simple stuff, people should be expected to plug these things in and out on a regular basis so it shouldn't be a kernel panic level issue when something goes wrong in that case.
At least you get a 'graceful' video driver restart when things go horribly messy on that platform (unlike XP where you just have a brick).

Where's the SDK, huh?

| No Comments | No TrackBacks
I'm just wondering when Apple will be shipping the SDK for the ipod touch/iphone. Just being nosey really. I've veered away from jailbreaking it simply because I don't want to end up with an expensive brick next firmware update.
They say February, but of course remembering that the Leopard launch being the end of the month it could be anywhere up to the 29th.
Another thing I'd like to see is the UI guidelines. I'm a bit of a nerd when it comes to reading design guidelines, simply because there are a lot of good points in them. Mind yo, you should not be slavishly obeying them, as, after all, they are only guidelines, and not commandments.
On guidelines, I'm get miffed with applications that require the use of the mouse to accomplish things. Vista's keyboard usable everywhere is a charm to use, even while it's gobbling up all those cpu and disk resources with the indexer.
Sometimes when people are using old painful versions of samba you can't use the encrypted passwords to talk to the remote server. You just get a complaint that the password is incorrect all the time, even though you keep typing the damned thing in correctly.
What you need in this case is an nsmb.conf file in ~/Library/Preferences/. It needs to contain a stanza:
[host you care about]
minauth=none
For every host that is not using high-falluting authentication. It would be better to not use a default entry here, as we want to ensure that the default attempt is not to try with unencrypted communications.

Whaddya mean no https

| 1 Comment | No TrackBacks
Leopard is not spiffy:
$ lwp-request -x https://mail.google.com/mail/
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://mail.google.com/mail/
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error
500 Can't connect to mail.google.com:443 (Invalid argument)
Update 2008-05-06: How I got it working for me. It's not the cleanest, but it works!
Apple have obviously made some significant backwards compatibility errors. Firstly, there's the firewall - altering the on-disk content of applications to make them signed when you accept them. Its an interesting approach, but it's complete pants. You don't go around altering binaries on disk. You create a detached signature! It's not really bloody difficult.
On Vista, you can see *every* rule that exists for the firewall. On Leopard, you only get to see the exceptions you created yourself.
I've been having random application crashes. They seem to be related to drag and drop operations that went wrong.
the calendar application does not want to talk to my instance of davical properly (all the calendars disappear after restarting, and I get an error every time I create a calendar). Then there's the 'the application terminated unexpectedly' - no, it didn't, I used the <Apple>Q menu item to quit the application.
Context sensitivity on the mail application is kinda limited - It doesn't detect URL links properly - I have a site that's called http://foo4/..., and all the link comes up with is http://foo. As I said, a bit limited.
Overall, though, the experience is positive. I would have preferred if apple had simply spent some more time testing the damned thing against anything other than their own applications and services.
And, as soon as they allow a replacement for .mac that can be replaced with an external, non-proprietary service I'll be a happier person

About this Archive

This page is a archive of recent entries in the Mac category.

Linux/Unix is the previous category.

Programming is the next category.

Find recent content on the main index or look in the archives to find all content.