Simply hit Cmd-Option-B and type something in the little search field in the bottom of the window.
Could maybe be a tad quicker (without having to
click to focus on the search field), but a really
useful feature nonetheless.
You could always just reset the password with the help of the OS X install disc, but there's an easier way and one that will actually let you restore the old password. All you need to know is the owner's user name (actually you can do some more dscl digging to use their real name as well).
You start off by booting into Single User mode (Cmd-S) and then:
# mount -uw /; sh /etc/rc
# cd /var/db/shadow/hashes
# guid=`dscl . -read /Users/username GeneratedUID | awk '{print $2}'`
# cp $guid $guid.old
# passwd username
# reboot
You can now log in as that user with your new password. When you're done, just boot back into Single User mode and mv the .old hash file back in place. Just to make sure you test that the owner can log in when they get back. ;)
My media library is another example (and I'm sure I'm not alone in this). I have tends of thousands of files stored on different mediums (computers and discs) within the confines of my home, only tens of meters apart, but when I need to find a single file, it's pretty much hopeless. While I can't really do much about my workdesk - it's just a force of habit, I'm still convinced I can do something about those files.
So what are the solutions?
1) Consolidate your storage by getting a bigger disk. I could image this working quite well. If I had about a terabyte of local storage, I could just store everything in one place, and use Spotlight to find it. Ofcourse, this is a band-aid. In a year, would need 2 TB, at least. It's also expensive.
2) Stop hoarding stuff. This isn't really an option for me, but the basic idea is that the really important data doesn't really take up much space. For me it's mostly text, with some pictures that I could easily fit within 10 GB. The rest (music and videos) is just enterntainment, right? Applications have become the most disposable form of "hd filler". But then you also have music bought from iTunes that you simply have nowhere else.
3) Start using some sort of DAM (Digital Asset Management) system. We're already doing this in many areas - Mail.app, iTunes, iPhoto, del.icio.us etc are all managing some assets. But which one should I install? I'm sure there's a really fancy and expensive solution out there, but all I really need is a generic tool that would essentially take snapshots of folders and then allow me to search them.
4) Hack Spotlight to support read-only media and file servers. I actually tried this, but after failed attempts to index SMB shares, I quickly gave up. Who knows, Leopard might help here, but I'm not betting on it.
Taking a snapshot of a folder on a UNIX system, is ofcourse a piece of cake:
> find ~/Movies \! -name '.*' > movies.txt
With more effort this could be made to check for duplicates (when importing the same folder again) and all sorts of cool things. Things will get hairy when I ned to store some extra attributes for an item. Like the QuickTime comment of a .mov or the year of an MP3. For this, a flat file becomes tedious.
The snapshot approach is really all I need - a medium-agnostic method for indexing and offline-searching file archives. So I'm starting yet another sideproject - a Python script that does exactly that. Here's what I have so far:
> ./lumi.py /Volumes/300G/Movies/
> importing /Volumes/300G/Movies/
> Successfully imported 1296 items
> ./lumi.py list
> 2007-03-17T12:22:23.827078 (/Volumes/300G/Movies/)
> 2007-03-17T12:23:04.715256 (/Volumes/Shared Items/Movies/)
> ./lumi.py name blender
> /Volumes/300G/Movies/Training (blendervt-interface-3dviewport-v234-r0.avi)
> /Volumes/300G/Movies/Training (blendervt-interface-concept-v234-r0.avi)
> /Volumes/Shared Items/Movies/Animation (Blender3d_SIGGRAPH2005_DVDRip.avi)
> /Volumes/Shared Items/Movies/Animation (BlenderTricksEpisode.avi)
The datastore is XML. Every import action has it's own Import element. This allows me to do things like undos etc. Oh, and the trick to getting Unicode to work somewhat properly, is to add:
import sys
sys.setdefaultencoding('iso-8859-1')
to /Library/Frameworks/Python.framework//Versions/2.4/lib/python2.4/site-packages/sitecustomize.py
While all of this is very basic ATM, it's already useful for me. No longer do I have to boot up a file server just find out if some music video is stored on it.
To set up a consistent environment, I compiled an Automator workflow that triest to simulate a typical writing scenario - grab a few HTML pages, find some words, create a new document in TextEdit, paste the text, pause for 5 mins, check email, repeat (I created the loop by adding an Open Workflow step that opened the same file). The display in this case is a 20" ACD. I also have a bunch of USB devices, but they're not used during the test so they should all be constants. Display Sleep was disabled and brightness was at maximum. The Mac was left to charge overnight between the test runs.
I run the script twice, fiirst with Black-on-White and then the opposite and measure how long the battery lasts, from being totally charged until it completely blacks out.
Luckily, Automator comes with a cli interface making it easy to measure the time. This is not 100% accurate because to stop the timer, I had to reconnect the power cord and kill automator:
> time automator /Users/filipp/Desktop/Loop\ test.workflow/
The results:
Black on white: 54m55.852s
White on black: 52m39.918s
So there's a difference, but it's the exact opposite - WOB actually gave a shorter battery life. I guess this could happen if the Mac is actually doing more graphics processing for the inversion and eating more power as a result. The difference is also so small, that there's really no need for another test.
> sudo fsaclctl -p / -e
and then we can just take away the right to delete:
> chmod +a "filipp deny delete" test
> ls -e
drwxr-xr-x + 5 filipp filipp 170 Mar 11 19:15 test
0: user:filipp deny delete
+a always adds an ACE, so to delete one:
> chmod -a# 0 test
Suhweet!
We all know what happens to Windows, and to some extent to OS X after you start installing stuff on them. But what I'd like to see is a benchmark of Windows with over 100 third party apps installed on it. This is exactly how many apps I have in my Applications folder (96 items in /Applications + sub-folders for stuff like browsers, games and server tools).
> system_profiler SPApplicationsDataType | egrep ":$" | wc -l
269
That's exactly how many apps I have on my system altogether, not counting system-level stuff. With that many apps in the registry, I would bet it would take the Windows PC longer to boot up than the Mac to finish the benchmark. If it would start up at all.
And this all comes back to the cost issue as well. Ask any Windows-using media professional and they'll tell you that you shouldn't install anything else except your bare necessities on your production workstation. That you should essentially have one machine for your video work and another for your email and P2P. But now you're already paying for 2 machines, aren't you?
filipp@fiBook.local [Metadata] > curl -v http://127.0.0.1/~filipp/collective/show.php?id=rss
* About to connect() to 127.0.0.1 port 80
* Trying 127.0.0.1... * connected
* Connected to 127.0.0.1 (127.0.0.1) port 80
> GET /~filipp/collective/show.php?id=rss HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l zlib/1.2.3
Host: 127.0.0.1
Pragma: no-cache
Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 24 Feb 2007 10:27:41 GMT
< Server: Apache/1.3.33 (Darwin) PHP/5.2.0
< X-Powered-By: PHP/5.2.0
< Set-Cookie: PHPSESSID=4fnmhuf56d5h3ifqg6qcai8k12; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Transfer-Encoding: chunked
< Content-Type: text/xml
AND
filipp@fiBook.local [Metadata] > curl -v http://localhost/~filipp/collective/show.php?id=rss
* About to connect() to localhost port 80
* Trying ::1... * connected
* Connected to localhost (::1) port 80
> GET /~filipp/collective/show.php?id=rss HTTP/1.1
User-Agent: curl/7.13.1 (powerpc-apple-darwin8.0) libcurl/7.13.1 OpenSSL/0.9.7l zlib/1.2.3
Host: localhost
Pragma: no-cache
Accept: */*
< HTTP/1.1 200 OK
< Date: Sat, 24 Feb 2007 10:28:51 GMT
< Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.7l DAV/2
< Last-Modified: Sat, 24 Feb 2007 10:05:15 GMT
< ETag: "3747e6-d1b-b6aecc0"
< Accept-Ranges: bytes
< Content-Length: 3355
< Content-Type: text/plain
When I open the page in a browser, the first one is returned regardless if I use localhost.
Just a silly Listen directive somewhere I'm sure, but goes to show what can happen when you start monkeying around with multiple web servers on the same machine.
<site base_url="http://mysite.com/" store_into="/Users/filipp/sitemap.xml.gz" verbose="1">
<directory path="/Users/filipp/Sites/mysite.com" url="http://mysite.com" default_file="index.html" />
</site>
Then just run sitemap_get.py and copy the resultant sitemap.xml.gz to your hosting site's root directory. The whole idea here is to match your RW export with your site's root on the server.
> ./configure --prefix=/usr/local/httpd-2.2 --enable-isapi --disable-mem-cache --enable-mime-magic --enable-ssl \
--enable-http --enable-dav --enable-cgi --enable-rewrite --enable-so --enable-headers --with-ldap --enable-dbd \
--enable-auth-digest --enable-authnz-ldap --enable-authn-anon --enable-mods-shared=most --enable-ldap --enable-cache
I think those features should make it more or less usable also in a real server environment.
Then, due to a bug in GNU libtool, you have to manually replace all the sys_lib_search_path_spec lines in two files - srclib/apr/libtool and srclib/apr-util/xml/expat/libtool to
sys_lib_search_path_spec="/Developer/SDKs/MacOSX10.4u.sdk/usr/lib"
After compiling and installing I had to go through the config files to make it more of a drop-in replacement for Apache 1.3. So that it works nicely with what's already there without actually replacing anything. Simply start with config/httpd.config and work through it and all the included files to check for any "incompatibilities" with OS X (document rooot, the www user, homedirs, tmp dirs, the usual).
Finally you just need an interface to control the server. Some fancier distros come with PrefPanes, mine simply has a StartupItem with the service name "Apache 2.2". You set this up by adding something in /etc/hostconfig (like APACHE22=-YES-) and then the relevant StartupItem into /LibraryStartupItems. So finally, to start our new server:
> sudo SystemStarter start "Apache 2.2"
You can't use launchd because it's not appropriate for wrapping things like apachectl.
Currently things seem to run nicely, I'm still testing stuff before maybe building a package. WebDAV works, which is nice.
It's incredible how many things you have to keep in mind to finally get a successful build out, a lot due to the fact that configure scripts don't seem to do any sanity checking between the different switches. For example, you can enable DAV, but if you forget to add any auth modules, nothing will work. Or the fact that --with-ldap and --enable-ldap are two different things - and you only find out that the first one (which isn't even mentioned in --help, btw) is compulsory if you want to add any kind of LDAP support. It took a lot of TTA to finally get this far...
> cd ~/Library/Application\ Support/Camino/chrome
> cat > ./flashblock.css << EOF
/* Prevent flash animations from playing until you click on them. */
object[classid$=":D27CDB6E-AE6D-11cf-96B8-444553540000"],
object[codebase*="swflash.cab"],
object[type="application/x-shockwave-flash"],
embed[type="application/x-shockwave-flash"]
{ -moz-binding: url("http://www.cs.hmc.edu/~jruderma/clickToView.xml#ctv"); }
EOF
and then just include that css file in your userContent.css:
> echo "@import url(flashblock.css);" >> ./userContent.css
I think this is a pretty useful thing to do to Camino since many Flash objects seem to slow it down to a crawl.
/Applications/TextEdit.app > Show package contents > Contents > Resources
Duplicate rtf.icns and rename copy to doc.icns
From the Contents folder open Info.plist and into the CFBundleDocumentTypes array append:
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>doc</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>doc.icns</string>
<key>CFBundleTypeName</key>
<string>Microsoft Word Document</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>W8BN</string>
<string>W6BN</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
</dict>
Then flush the LaunchServices cache (this will reset all document/app associations so be prepared to be annoyed):
> cd /System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support
> ./lsregister -kill -r -domain local -domain system -domain user
> sudo pmset displaysleep 1
is great, but requires root prvileges (due to some of the other things you can do with it) so it's out for any kind of automation/scripting purpose.
Enter Apple Remote Desktop. Among other niceties, ARD includes a CLI utility called systemsetup that you can use to set various system preferences, like so:
> /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup -setdisplaysleep 30
Nice. Time to wrap this into something Mac-like and give it a keyboard shortcut:
property ARDPath : "/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/systemsetup"
set currSleep to do shell script ARDPath & " -getdisplaysleep"
if (currSleep) does not end with "1 minutes" then
set newSleep to 1
else
set newSleep to 30
end if
do shell script ARDPath & " -setdisplaysleep " & newSleep
Throw that into ~/Library/Scripts and give it a fitting shortcut in System Prefs/Keyboard & Mouse.
Pretty nice. I only wish QuickTime Player had such
a nice Automator Library...
Because this is implemented on the fs level, it's very fast and totally transparent."A snapshot is a read-only point-in-time copy of a filesystem which takes practically no time to create and uses no additional space at the beginning. Any snapshot can be cloned to make a read-write filesystem and any snapshot of a filesystem can be restored to the original filesystem to return to the previous state."
* Dynamic striping. ZFS not only promises much improved consistency, but also performance. Dynamic striping allows to write to all devices in a "pool" simultaniously.
Here's a nice 10-point list of the advantages and a Flash animation of ZFS in action.
Boot support is not actually implemented in the FS. Because it's such a low-level thing, it has to be implemented in the actual hardware (ROM). This is definitely something that will set the PPC and Intel Macs apart one day since the Intel machines have EFI which is a modern programmable BIOS that Apple will probably one day update to support booting from ZFS.
A: Yes it is.
Q: Mmkay, but how?
A: I'm glad yo asked. With ioreg and a few extra utilities, like awk:
ioreg -n IOHWSensor | awk -F "=" '/\"current-value\" = (\d*)|\"location\" = (\d*)/ { print ($2); }'
That will output:
3031040
"HDD BOTTOMSIDE"
3309568
"CPU TOPSIDE"
3440640
"GPU ON DIE"
80033
"CPU CORE"
307429376
"REAR MAIN ENCLOSURE"
1900544
"BATTERY"
As you can see the numbers don't make any sense. And this where the amazing "Mac OS X System Internals" comes in. In chapter 10.7 "A Programming Tour of the I/O Kit's Functionality" (page 1307) we find that the values should be bit shifted right by 16. So here's another example, in Python, with the bit shift applied:
import commands
ioreg = commands.getoutput ('/usr/sbin/ioreg -n IOHWSensor')
k = re.findall ("\"location\" = \"(.*?)\"", ioreg)
v = re.findall ("\"current-value\" = (\d*)", ioreg)
aDict = dict (zip ([lower (el) for el in k], [int (el) >> 16 for el in v]))
Giving us the temps in centigrade:
{'gpu on die': 52, 'battery': 29, 'cpu topside': 49, 'rear main enclosure': 4732, 'cpu core': 1, 'hdd bottomside': 46}
This code also wraps the results in a nice Python dictionary. 'rear main enclosure' is obviously the RPM of the only fan this machine has.
Here's the output from running the shell command on a G5:
476
"CPU T-Diode"
107
"CPU Current"
823
"CPU Voltage"
124
"Slots Power"
2097152
"DRIVE BAY"
hw_prefs machine_type
Many thanks to all the people who helped me piece this one together!
Add Automator > Run AppleScript action and:
tell application "Finder"
empty trash
end tell
Can I have some money now? ;-)
/SourceCache/JavaScriptCore/JavaScriptCore-418.3/bindings/objc/WebScriptObject.mm
/SourceCache/apache_mod_php/apache_mod_php-18.4/php/configure
What are they?
My guess is they're the development environment directories at Apple.
ln -s /my/shared/folder /Applications/KDXServer1600/Bases/Default/Downloads.
Create a LaunchDaemon (from haxial.com):
sudo nano /Library/LaunchDaemons/com.haxial.kdxserver.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.haxial.kdxerver</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/KDXServer1600/KDXServer.command</string>
<string>--bkgnd</string>
<string>--nohup</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Load the daemon:
$ launchctl load -w /Library/LaunchDaemons/com.haxial.kdxserver.plist
$ launchctl start com.haxial.kdxserver
http://developer.apple.com/macosx/launchd.html
man 5 launchd.plist
Software Update wouldn't work ("There were errors bla-bla-bla). Installing from PKG gave a better error (checking from install log) something about broken DiscRecording Frameworks. Repair Permissions had this to say:
Symbolic link ./System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CFNetwork.framework/Versions/Current->A repaired
Symbolic link ./System/Library/Frameworks/DVDPlayback.framework/Versions/Current->A repaired
Symbolic link ./System/Library/Frameworks/DiscRecording.framework/DiscRecording->Versions/Current/DiscRecording repaired
Symbolic link ./System/Library/Frameworks/DiscRecording.framework/Frameworks->Versions/Current/Frameworks repaired
Symbolic link ./System/Library/Frameworks/DiscRecording.framework/Resources->Versions/Current/Resources repaired
Symbolic link ./System/Library/Frameworks/DiscRecording.framework/Versions/A/Frameworks/DiscRecordingContent.framework/Versions/Current->A repaired
Symbolic link ./System/Library/Frameworks/DiscRecording.framework/Versions/A/Frameworks/DiscRecordingEngine.framework/Versions/Current->A repaired
Symbolic link ./System/Library/Frameworks/FWAUserLib.framework/Versions/Current->A repaired
Symbolic link ./System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current->A repaired
Symbolic link ./System/Library/PrivateFrameworks/AppleVA.framework/Versions/Current->A repaired
Symbolic link ./System/Library/PrivateFrameworks/BezelServices.framework/Versions/Current->A repaired
Symbolic link ./System/Library/PrivateFrameworks/Bom.framework/Versions/Current->A repaired
After this and a 10.4.7 Combo Install, the machine worked fine again.
Another example, Activity Monitor wouldn't start, system.log had this to say:
2006-10-17 16:07:18.904 Activity Monitor[21307]
The tool is not setuid root - please repair the
privileges
Needless to say, repairing permissions fixed the problem. I've also seen cases where no application would launch - meaning you get the "blinking desktop" problem with the Finder constantly trying to start itself up. It was caused by a broken /tmp symlink (which in OS X links to /private/tmp, and we also have /var/tmp!) which Disk Utility nicely repaired.
Repair Permissions is often called the "PRAM zap of the 21'st century" and I agree. But just as a PRAM zap could fix a no-video issue, Repair Permissions can also help sometimes.
>./configure --prefix=/usr/local --mandir=/usr/local/share/man --with-ssl --with-apxs=/usr/local/apache2/bin/apxs --with-zlib --without-berkeley-d
> httpd.conf
## SVN
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
WebSVN:
include/config.inc
> nano include/setup.inc > languages/english.inc
> mkdir /usr/local/subversion/repos
> sudo svnadmin create /usr/local/subversion/repos
> mkdir branches tags trunk; mv MyProject/* trunk
> svn import MyProject file:///usr/local/subversion/repos
> chown -R www:www /usr/local/subversion/repos
Machine B
> svn checkout http://host/ project
Authentication
> htpasswd -cm /path/to/htpasswd/file user
> nano -w httpd.conf
DAV svn
SVNPath /path/to/repos
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /path/to/htpasswd/file
Require valid-user
XCode:
SCM Config > Subversion > /usr/local/bin/subversion --username user --password pw
http://www.alajaam.net/websvn
