Finder Tip
File browsing on OS X, is not always the most easy experience, but I have found some optimisations recently. I tend to find I have a Finder window open, a Bash shell open and at times need to locate files in an open-file app dialog. The first two (Finder & Bash) can be linked quite nicely with a simple script. And it turns out Finder and the Open File dialog can also be linked very conveniently. Here’s how:
When the file dialog is open, alt-tab to Finder. Then click & drag the folder or file you wish to select in the file dialog, and then alt-tab back & drop that on the bottom gray bar of the dialog. It will then be selected in the open file dialog, allowing you to select it, or deselect and pick a file around it. Neat!
When the thumbnail resize bar doesn’t work in OS X Lion
I’ve encountered this bug for many years now and it shits me to tears.
![]()
OS X has this great little thumbnail resize bar at the bottom right of Finder’s status bar that lets you change the size of photos you are viewing in Finder. It’s a great way to explore your travel photos, without any 3rd party software. However, inexplicably about half the time it seems to just not work.
Well it is a glorius day as I found the solution. You can fix this by toggling the status bar off & on. The easiest way to do this is via the shortcut (twice) ⌘/
Thanks to Tony T1 for the tip.
My 2012 New Mac Installation
So after migrating a mac installation around starting in late 2008 from a Mac Mini, to a MacBook, to a new MacBook it has finally become too bloated. The mac won’t poweroff correctly when it shut down, nor does the sleep settings always work correctly, after installing a new SSD in the Mac, I figured I may as well start afresh instead of migrating *yet again*.
Here are my reinstallation notes. I’ve put it up here mostly for my own convenience in case I have to do it again soon – but also since who knows, maybe it can help someone else out there? For the record, I need to have iOS development configured, plus ruby on rails, MySQL and PHP.
- User-apps: Chrome (Bookmarks sync’d through my Google Account), Skype
- To save time, I copied XCode from my MacMini which I had downloaded earlier (but not used). This seemed to work, I then installed the command-line tools, simulator, etc via XCode
- MacPorts installed
sudo port install ImageMagick# I’ll need this later, so may as well start it going now- RVM installed via the script
- Ruby installed with: rvm install ruby 1.9.3. To do this, I had to first install the command line tools from XCode, and run
sudo xcode-select -switch /Applications/Xcode.app sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist# I like using the `locate` command from bash, this enables that- Enabled PHP:
sudo chmod +w /private/etc/apache2/httpd.conf# make writablesudo vi /private/etc/apache2/httpd.conf +/php# open and search for PHP- # uncomment the module loading, so it will load & save
sudo chmod -w /private/etc/apache2/httpd.conf# leave it how I found it- Install the latest version of MySQL
- Download
- Server installed
- Double-click the preference panel to add start-stopping into your system prefrences
- Install the start item. Since I didn’t want it to actually start on boot right now, I also:
sudo vi /etc/hostconfig +/MYSQLCOM- set the ‘YES’ to ‘NO
- mysql isn’t added to your PATH by default, so:
vi ~/.bashrcPATH=$PATH:/usr/local/mysql/bin/sudo /usr/libexec/locate.updatedb# some stuff has changed- Migrating some settings from my old installation:
cp -pr /Volumes/OldMac/Users/will/Library/Keychains/login.keychain ~/Library/Keychains/login.keychain- copied the .ssh directory
cp -pr /Volumes/OldMac/Users/will/.ssh ~/ - Reclaiming Finder
chflags nohidden ~/Library/- Command+Shift+H, Command+Up Arrow (quick way to view your home dir), dragged ‘will’ into my favourites
- Re-listed my HDD’s on the left & changed the default screen when Finder opens to be my home dir, not ‘all files’, as per these great tips.
- Installed the handy open console at finder location script.
- Ruby setup
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib"# added to my .bash_login so mysql2 will compilesudo gem install mysql2# I prefer to install gems with native extensions directly, to catch any build problems rather than through bundlerbundle install# from my rails project, to get the rest- In XCode, rather than re-importing the developer profiles from the developer website, I just hit the ‘refresh’ button under Devices->Teams to download them automatically
That’s it. Pretty painless really, installing ruby via RVM, then all the gems via bundler is just so easy these days!
This page has some useful tips on manual migrations, you can pick & choose what you need.
Ammendum:
Transmit’s favourites are located here: ~/Library/Preferences/com.panic.Transmit.plist (thanks dkocher)
iPad RFE – Show Photos from SD Card
I love my iPad. Well, I do use it a little bit less now I have a kindle for ebooks (lets face it, eink nicer to read for black&white content than a glowing screen, even a resolutionary one, more on that later).
I even bought the $30 camera connection kit (before I found the ¥20 (~$3) one in China that is not only cheap, but gives you about 5 different memory cards in the one device).
I just wish I could plug in my SD card and display photos from it without having to import them all. Importing sucks for several reasons: a) it’s slow, b) it takes up space on my iPad, c) it then takes up space on my computer when I backup my iPad d) when the photos have a RAW component, it gets imported too, further exacerbating points c & d, without really adding anything to my slideshow. My 16GB of photos – backed up on my computer already, uses another 16GB on my iPad, and then a further 16GB backup on my computer.
Maybe I shouldn’t admit this – but being forced to import photos in order to show them is the No. 1 reason why I didn’t just buy the 16GB new iPad when I upgraded last week, as there simply isn’t enough working space for me do to this on a long trip. Hey I’ll give Apple tonnes of my heard earned cash just the same, I promise – there really isn’t a need to force me for this particular upgrade.
My final gripe is that the camera connection kit doesn’t work on the iPhone. Why can’t I plug in my DSLR’s memory card & add photos to my spikes (preferably without importing first, see above)?
Another Year, another Symbolication Problem
For me, this is an annual event it seems: struggling to get XCode to symbolicate stuff so it’s actually useful. The task: get symbols in my Instruments so I can see which bloody method is taking 10 seconds to execute.
The problem always seems to be Spotlight, which is used to locate the builds.
To cut a long story short: XCode places the dSYM files for the *current* build in ~/Library/Developer/Xcode/DerivedData and the dSYM’s for your archived builds in ~/Library/Developer/Xcode/Archives/ (if you’re using finder you’ll have to use ‘show package contents’ on the builds to see what’s inside).
Aside: is your Library directory hidden in Lion: chflags nohidden ~/Library/ to unhide.
Now the last time I was trying to symbolicate it was crash dumps, and some advice on SO advised me to add the DerivedData folder to my Spotlight exclusions so the symbolicator doesn’t get confused (I believe it worked at the time), of course this messes with symbolication Instruments, so be sure to remove it.
I love it when you can avoid Spotlight altogether, which just seems so flakey for things like this – and there is a good way (alt). I’ll summarise it here:
- With Instruments stopped, click on File -> Re-Symbolicate Document
- Search for your app name
- Click “Locate” and choose your dSYM from
~/Library/Developer/DerivedData/APP_NAME-XXXXXXX/Build/Products/[BUILD_TYPE]-[DEVICE-TYPE]/ - Click the Start button to begin profiling
With step 4, it’s possible you may have multiple folders with the same app name. The easiest way to find the one you need is to order by modification date, and pick the most recent.
For me, this fixed up Instruments on a per-execution basis, without needing to trick Spotlight into action. I expect once Spotlight has a chance to sort itself out, it may just work but you won’t find me holding my breath.
mod_rewrite generator
I just want to say that this is a totally awesome mod_rewrite generator.
I need a 3TB Dropbox
click, click, every time I take a photo, I’m adding more data to my personal permanent record (DSLR raw photos exceed 12MB, and the iPhone’s are not small either anymore with the 4S). I love taking photos, and I never delete them. Add that to all the work I create, and my music collection and there are a lot of files that I hold precious.
Not only that, but as someone who travels a lot, I really want them backed up on the cloud, and accessible from everywhere.
Basically, I need a 3TB dropbox. One with clients like the iOS client for Mac which allows me to selectively upload and download files (without forcing everything to sync). Effectively, a source of truth for my data.
What I can’t believe in 2012, is that unless I pay thousands of dollars a year (for S3), such a thing doesn’t seem to exist in the budget range.
BackBlaze appears to come closest with cheap, offsite storage. They’ll even backup an external volume (not exactly what I need, since it wouldn’t be possible to add file to this without also carrying it), but pretty close. With one big catch. They delete all data that isn’t attached after 30 days. Wow, how crap. Yes, they will completely delete a 2TB backup (that could have taken you months to upload) if you turn on your computer without the external HDD attached. Maybe rather than offering unlimited backup, they should charge by the GB and offer my desired “giant dropbox” solution.
Box.com appears to almost offer a decent solution. $15/month for 1TB. The price works. However you must buy 3 users minimum (why not 1 user with 3x the space?). I’ve emailed to ask them if they can offer a 3TB account, I wonder what they will say?
Hashbangs vs pushState
When Twitter jumped on the hashbang bandwagon, it prompted me to consider it too. I even did up a quick prototype on Geospike to see it working. Something made me uneasy though, so I put in on ice.
I’m happy I did, as these are some very convincing arguments against hashbangs, and for pushState. Using pushState alone means you can’t support IE, but as the author states “are page refreshes that bad?” – it is possible to make page loads fast, and this is a good example of something degrading gracefully.
Interesting summary of the conversation, and more pushState info.
Rich & Poor
The rich and poor alike, can stay at home and do whatever they like. And the middle class pay for both of them.
stdin, stdout, stderr with proc_open in PHP
Want to use PHP as part of your toolchain? It’s a bit painful. If you want to pipe in some data from memory, and read it back into memory (why not! using tmp files is for wimps).
here’s the solution, thanks to richard at 2006 dot atterer dot net
// $command is the command to run, $stdin is your input. You get back $stdout and $stderr and $returnValue
// you'll probably want to wrap this in a function ;)
$descriptorSpec = array(0 => array("pipe", "r"),
1 => array('pipe', 'w'),
2 => array('pipe', 'w'));
$process = proc_open($command, $descriptorSpec, $pipes);
$txOff = 0; $txLen = strlen($stdin);
$stdout = ''; $stdoutDone = FALSE;
$stderr = ''; $stderrDone = FALSE;
stream_set_blocking($pipes[0], 0); // Make stdin/stdout/stderr non-blocking
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
if ($txLen == 0) fclose($pipes[0]);
while (TRUE) {
$rx = array(); // The program's stdout/stderr
if (!$stdoutDone) $rx[] = $pipes[1];
if (!$stderrDone) $rx[] = $pipes[2];
$tx = array(); // The program's stdin
if ($txOff < $txLen) $tx[] = $pipes[0];
$ex = NULL;
stream_select($rx, $tx, $ex, NULL, NULL); // Block til r/w possible
if (!empty($tx)) {
$txRet = fwrite($pipes[0], substr($stdin, $txOff, 8192));
if ($txRet !== FALSE) $txOff += $txRet;
if ($txOff >= $txLen) fclose($pipes[0]);
}
foreach ($rx as $r) {
if ($r == $pipes[1]) {
$stdout .= fread($pipes[1], 8192);
if (feof($pipes[1])) { fclose($pipes[1]); $stdoutDone = TRUE; }
} else if ($r == $pipes[2]) {
$stderr .= fread($pipes[2], 8192);
if (feof($pipes[2])) { fclose($pipes[2]); $stderrDone = TRUE; }
}
}
if (!is_resource($process)) break;
if ($txOff >= $txLen && $stdoutDone && $stderrDone) break;
}
$returnValue = proc_close($process);
I previously had an implementation using `fwrite` and `stream_get_contents` as some other people, and the docs suggested, which works fine for small inputs, but once you get something bigger than ~200k input, it can completely deadlock.
This implementation is better as it reads and writes the data when needed, keeping everything flowing and alive.

