| categories: | all | general | read | tech |
| tags: | blog server tech vim |
|
After upgrading to Mac OS X 10.5 Leopard, my logs were getting spammed with the followoing error: com.apple.nis.ypbind: Domain name not set. Aborting.Deleting the /etc/defaultdomain file fixed the problem.
Posted by: Seth Milliken
[ 0 ] Comments I wanted to set up a second site on a machine that was already hosting, so I looked into setting up VirtualHosts. Here are some bits that I learned that were not in the documentation or clear from the documentation. Everything outside of the VirtualHost containers are default settings for all containers. The first container is the default; if no container matches the requested host exactly, the first one will be used. So don't use a servername or serveralias in that container if you want a last resort default. You'll want to specify ServerName, ServerAlias, and DocumentRoot as minimum settings in your subsequent containers. # Main configuration # Example settings... ServerName default.mydomain ServerAdmin admin_address@mydomain User www Group www DocumentRoot "/default/docroot" <Directory "/default/docroot"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> IndexOptions FancyIndexing VersionSort IndexOptions NameWidth=* IndexOptions IconWidth=16 IndexOptions IconHeight=16 IndexOptions SuppressDescription # ... other index settings # ... many other settings # Use name-based virtual hosting. NameVirtualHost * # Default host <VirtualHost *> # no ServerName directive ErrorLog "logs/default-host-error.log" CustomLog "logs/default-host-access.log" common # These lines let us use the rewrite rules defined in the main configuration. RewriteEngine on RewriteOptions inherit </VirtualHost> <VirtualHost *> ServerName virtualhost1.mydomain ErrorLog "logs/vh1-host-error.log" CustomLog "logs/vh1-host-access.log" common DocumentRoot "/some/other/docroot" <Directory "/some/other/docroot"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> # to enable serving up default "~/Sites" directories on Mac OS X UserDir "Sites" </VirtualHost>
Posted by: Seth Milliken
[ 0 ] Comments Why is it so freaking hard to bind a keyboard shortcut to putting the displays to sleep immediately in Mac OS X? In the classic Mac OS, there was a hot key that did just this, at least on PowerBooks (I can't remember exactly what it was, and I don't think it was remappable, but it was there). Whenever I stepped away from my PowerBook or didn't anticipate needing to use it right away, I could tap those keys and the backlight would instantly shut off, saving some precious juice. Nowadays, my laptop usage patterns are a bit different and I don't tend to need to squeeze out every last minute of battery life anymore. But on the desktop machines I use regularly, which have no fewer than four displays connected to them, I want to be able to put all of those displays into power saving mode immediately. The main reason is so that my bedroom isn't lit up like a Christmas tree when I want to go to sleep, but I also prefer not to waste power needlessly and hope to maybe get a little more life out of the LCD backlights by turning them off when I'm not actually using them. Let me note here that even with a black screen, LCD backlights still generate a fair amount of light; the displays really need to be off. Another factor is that not all of the displays can be plugged into the same power strip, enabling me to turn them all off and on with a single flip of a switch (e.g. Apple Cinema Displays get their power directly from the computer they are plugged into). And anyway I prefer to have a uniform mechanism for controlling display sleep regardless of which machine I'm using and whether the energy saver settings have put the displays to sleep or I have done so explicitly. Besides, it's nice to be able to just hit a key on the keyboard to wake up the displays. I think that covers the reasons why I want this feature, and hopefully preempts some of the not so helpful suggestions I've seen other netfolk offer in response to similar pleas. Prior to Leopard, I had a shell script that looked like this:
#!/bin/sh
MAGIC_NUMBER=107374183
PMSET=/usr/bin/pmset
GREP=/usr/bin/grep
AWK=/usr/bin/awk
SLEEP=/bin/sleep
$PMSET force -a displaysleep $MAGIC_NUMBER
$SLEEP 1
$PMSET force -a displaysleep `$PMSET -g | $GREP displaysleep | $AWK '{print $2}'`
$SLEEP 1
I was able to use a QuickSilver to bind execution of this script to a function key and I was mostly happy. It executed very quickly, and did just what I wanted it to do. But as you can see, this script relies on a magic number—one that is undocumented and is possibly even the result of a bug. Now that I've upgraded to 10.5, this magic number no longer works; the script does nothing. Without a working magic number, the best you can do with a script like this is have the display sleep after one minute (the lowest effective pmset displaysleep argument is 1; 0 disables display sleep altogether). Leopard introduces a new feature that allows you to bind a screen corner to "Sleep Display". So now this instant display sleep feature is explicitly supported in the operating system. Sort of. As far as I can tell, there is absolutely no way other than the hot corner to access this feature. Nothing in AppleScript, nothing in pmset, nothing in keyboard shortcuts, no menu item, no hot keys documented or otherwise, nor even a system level API that I could use to write a stupid little Cocoa app. I hope I am wrong; this omission aggravates me much more than it really ought to. UPDATE: Malcolm Hall has come to the rescue with SleepDisplay.app. Thank you, Malc!
Posted by: Seth Milliken
[ 1 ] Comment I'm migrating blogs hosted at araxia.net from MoveableType to blojsom. I'm posting the status on the migration here.
Posted by: Seth Milliken
[ 0 ] Comments I was poking around in iStumbler and noticed a "Secure File Sharing" option which mapped to sftp-ssh. Looking through the various directories responsible for providing services in Mac OS X, I discovered that the sftp-ssh service is provided by the ssh launchd daemon. So by enabling the "Remote Login" option in the Sharing System Preference Pane, you automatically get sftp. Cool.
Posted by: Seth Milliken
[ 0 ] Comments Prior to Mac OS X 10.5 (Leopard), there was a bug that made using the Universal Access zoom feature (accessible by default with Option-Command-8) useless in a multiple display configuration in which the virtual heights of the arranged displays differed. As soon as you activated the zoom feature, the portal created by your displays would lock essentially to the height of the primary display, making it impossible to scroll to the portions of the virtual screen that mapped to the higher or lower displays, and in some cases you couldn't even see the menu bar. Basically, you could pan horizontally across your virtual screen, but not vertically. This might not make any sense to you if you never tried this yourself, but they fixed this in Leopard and I'm happy about that.
Posted by: Seth Milliken
[ 0 ] Comments I have been using FireFox as my primary browser for quite a while now. What held me back from switching initially were two things: 1) unacceptably poor non-native widgets, which have since improved dramatically and 2) no support for the Mac OS X Keychain, which is now available via the Keychain Services Integration extension. But eventually my desire for vim keybindings everywhere pushed me to switch despite these shortcomings. The vimperator FireFox extension allows for entirely keyboard-based browsing, using bindings similar to vim. And even better, it facilitates form field editing using vim via external editor support. So when I want to edit a form field, I type either "gi" (to enter the field) or "f#" (where # is the QuickHint mode number associated with the field; useful if there are multiple fields on the page) then hit Control-i. This creates a new tab with a buffer for that field in an existing instance of MacVim which is always running in the same Space as my browser, so it comes up almost instantaneously. I edit the contents of this buffer using all the goodness of native vim and then type ZZ. Thanks to a couple of autocommands in my .vimrc, this saves the buffer, saves a copy of its contents in a timestamped archive file, closes the buffer, and then hides MacVim, leaving FireFox active with the text I just wrote inserted in the form field ready to submit. Here are the requisite pieces of the puzzle: .vimperatorccThis is the vimperator configuration file. You need to add a line to set your external editor to the script that opens MacVim.set editor="~/bin/vimperator" shellMake a symbolic link to your mvim script so that the script can detect the context it's running in.ln -s ~/bin/mvim ~/bin/vimperator mvimThis is the mvim script that comes bundled with MacVim, moved to ~/bin and modified. Add this bit to the 'case "$name" in' statement:*vimperator) opts="$opts --remote-tab-wait-silent" gui=true ;; .vimrcNext, a couple of additions to the vim configuration file to make ZZ save the contents to an archive, close the buffer, and return FireFox to the foreground.augroup Vimperator au! BufRead vimperator-* nnoremap <buffer> ZZ :call FormFieldArchive() \| :silent write \| :bd \| :macaction hide:<CR> au BufRead vimperator-* imap <buffer> ZZ <Esc>ZZ augroup ENDFinally, here is the function that saves a copy of the form field contents to an archive file, complete with timestamp and url:
function! FormFieldArchive()
let l:contents = getbufline("%", 1, "$")
let l:filepath = expand("%")
let l:filename = expand("%:t:r")
let l:formfielddir = $HOME . "/webforms/"
let l:currentdate = TimestampText('date')
let l:entry = l:formfielddir . l:currentdate . ".txt"
let l:entryexists = filereadable(l:entry)
exec "split " . l:entry
if l:entryexists
normal Go
normal o
exec "call setline(\".\", \"" . TimestampText('time') . "\")"
else
exec "call setline(\".\", \"" . TimestampText('journal') . "\")"
exec "silent !svn add " . l:entry
endif
normal o
exec "call setline(\".\", \"" . l:filename . "\")"
normal o
exec "call setline(\".\", " . string(l:contents) . ")"
write
bd
endfunction
This will create a new file with the current date, e.g. "2010-03-15.txt", if it doesn't already exist. If it does exist, it will add the entry to the end of the file separated by a timestamp. TimestampText() is just a convenience function I wrote that returns a timestamp in various strftime() formats.
Posted by: Seth Milliken
[ 0 ] Comments |
Links
araxia.net blog status
del.icio.us bookmarks Facebook Profile LinkedIn Profile last.fm home résumé photos tomcat svn hg
Contact Information
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
categories:
/ |
html hits: 2135