Clutter in programmer workspaces, whether digital or physical, add a mental
cost. An area of common clutter is the
~/Downloads directory in Mac OS X.
I want to clean it up… programmatically.
I want a background job to find files in
~/Downloads which haven’t been
modified within the past week and move them into
~/.Trash. In zsh, we do:
mv ~/Downloads/*(mw+1) ~/.Trash
man zshexpn for more awesomeness on shell expansion.
For a user-specific background job, Apple recomends creating a Launch
Agent, which is a
file located in
~/Library/LaunchAgents/com.thoughtbot.cleandownloads.plist will run my
script once an hour:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.thoughtbot.cleandownloads</string> <key>ProgramArguments</key> <array> <string>mv</string> <string>~/Downloads/*(mw+1) ~/.Trash</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>1</integer> </dict> </dict> </plist>
Read Creating Launch Daemons and
Agents for more on
how to structure the
Ain’t nobody dope as me, my Downloads directory is so fresh and so clean clean.
Earlier today, OS X Mountain Lion was released for all users in the Mac App Store. As a member of the Mac Developer Program, I decided to tame this wild cat early on, jumping on the beta tester bandwagon since the Developer Preview 4. Here are some of the things you should consider as you make the switch to this shiny new operating system.
After I downloaded the 4GB installer from the Mac App Store, the whole upgrade process took me about 45 minutes on my 15” 2010 Macbook Pro with an SSD drive. It was a simple and straightforward process as the installer takes care of everything.
Once the installer is done, we need to do some additional work to get up to speed once again and be able to compile Ruby (using RVM or rbenv) or install packages using Homebrew. Hold on to your champagne for now.
You can get Xcode from the Mac App Store. You’ll need at least version 4.4 of
Xcode for it to work with OS X Mountain Lion. After the installation, open up
Xcode in your
/Applications folder. You’d want to go to Xcode -> Preferences
-> Downloads tab then install the “Command Line Tools.” After you’re done, quit
Xcode and fire up Terminal.
After the upgrade, Apple will set the ownership of your
/usr/local folder to
root. You can easily fix this by running this command in Terminal:
sudo chown -R `whoami` /usr/local
Next, you need to update Homebrew:
If you need to install any Ruby that’s older than 1.9.3, such as 1.9.2, 1.8.7
or REE, you’ll need to install GCC 4.2. Apple does not ship the Command Line
gcc-4.2 compiler anymore (you can check by running
gcc-4.2), so you need to install it via Homebrew. By default, Homebrew doesn’t
include any formula that ships with the OS in the main repository, so you’ll
have to enable homebrew-dupes repository by using
brew tap homebrew/dupes brew install apple-gcc42
Voila! Now you can compile any library that requires non-LLVM GCC.
Note: If you were using a binary package from MySQL website to install your MySQL server, you will need to change the ownership of your MySQL data directory back by issue this command:
sudo chown -R mysql:mysql `brew --prefix`/mysql
Now, if you’re still using some application that depend on X11, such as Divvy or gitk, you’ll need to install X11 as well. Apple has already removed X11 support from their operating system, but you can still get the X11 package from XQuartz. I’ve been using their 2.7.2 release, and it’s working fine for me.
Before performing any major upgrade, always make sure that you have the latest backup of your Mac. If you already have Time Machine set up, all you need to do is intiate another manual backup. It’s also a good idea to verify your backup afterward to make sure that it’s working.
If you have been leading a carefree life and did not bother setting up Time Machine, or would like to make sure that you can come back to Lion if something is broken, I would suggest using Carbon Copy Cloner to clone your internal hard drive to an external one. (Once the upgrade is done, I would still recommend you set up Time Machine.)
Finally, your developer machine has been upgraded to OS X Mountain Lion. I hope you’ll enjoy the new features as much I do. Happy coding!
When installing Ruby 1.8.7 with rbenv, there were compilation issues due to an issue with Tk. After digging through the output log, it turns out it was looking for an Xlib header and failing. This can be resolved by exporting an additional include path to GCC:
Mike Burns, the usual author of this post, was out last week so I’m filling in. Sorry it’s a little late. As usual we had a ton of activity around our open source projects.
Paperclip, our popular gem for image attachments, got a few bug fixes. Jeff Dutil (jdutil) changed the travis-ci build image to use https so that Github wouldn’t cache it (c0c9b69) meanwhile, David Faber (faber) fixed a bug with the :fog_public attachment option. Evgeniy Dolzhenko (dolzenko) pointed out a typo in one of the matchers (9f38928). To top it off our own Prem Sichanugrist (sikachu) configured Travis CI to test against REE (ab7db5a).
Factory Girl, the gem that provides factories for readable tests, got a ton of love this week. Jeff Dutil (jdutil) fixed the travis-ci images yet again (40d08ee). Our own Josh Clayton (joshuaclayton) and Thomas Walpole (twalpole) colaborated to add traits. Josh pushed out a new release too. Read the blog post or look at the commits to find out more. Ken Collins (metaskills) fixed a bug with the way overrides dealt with attribute definition order (4b83b1e). Thomas also fixed another attribute related bug (2ccbf45). Josh also fixed some issues with dynamic attributes of file attributes (8012d3d). Josh also bumped the version to 2.0.4 (be14aa) and replaced rr with mocha for mocks (554e6ab).
Cappybara-Webkit, the headless browser that runs your tests at lightning speed, got a few bug fixes too. Joe Ferris (jferris) disabled custom fonts to prevent crashing on OS X (82ae0c2).
Paul Revere, the gem that lets you easily add one off announcements to rails apps, got some documentation love this week from Matt Jankowski (mjankowski) He added usage documentation (810f6aa, f09b757) and fixed some existing documentation (2758eb1).
The fabulous vanilla sass mixins gem got some care from thoughtbot’s Phil Lapier (plapier). He changed the file extensions from .css.scss to .scss (2465a17) and released version 0.1.4 (920785d).
Lots of changes in Kumade! It now uses a deploy branch for committing assets (2e11258), which means that those ugly Jammit compilation commits for Heroku don’t show up in your github repo. It no longer requires the
deploy subcommand, so you can just do
kumade staging instead of
kumade deploy staging. It no longer detects the Cedar stack by default (bce4682), since
heroku stacks requires permissions that you may not have, even if you can push to it. Instead, use the “-c” flag to indicate that your app uses the cedar stack. And just today, it got better integration tests (39fd463, f5902ae, 657f63d). None of these changes are released in a gem yet, but you can get it via git:
gem "kumade", :git => "git://github.com/thoughtbot/kumade.git".
Last but not least is Laptop, thoughtbot’s one stop shop for setting up a development environment. thoughtbot’s Dan Croak (croaky) changed the readme to recommend a standalone install of GCC instead of xcode (38d2458). He also added tmux (531645d) and updated the default ruby from 1.9 to 1.9.2 (a29cbe7). John Deerhake (jdeerhake) chipped in with a fix for ack on ubuntu (557736b).
Want to see your name on this list? Fork one of our projects and submit a pull request (with tests).