Postpostmodern » Mac http://postpostmodern.com Speaking of web development. Wed, 11 Jan 2012 00:21:50 +0000 http://wordpress.org/?v=2.9.1 en hourly 1 Terminal Tip: Delete Those Mac Dot Files http://postpostmodern.com/2009/06/08/terminal-tip-delete-those-mac-dot-files/ http://postpostmodern.com/2009/06/08/terminal-tip-delete-those-mac-dot-files/#comments Mon, 08 Jun 2009 16:40:32 +0000 Jason Johnson http://postpostmodern.com/?p=396 Unzipping/untaring an archive that was created on a Mac can produce a lot of ._blah and .DS_Store files. Rid yourself of them with:

find . \( -name '._*' -o -name '.DS_Store' \) -exec rm {} \;

or, if you’re using GNU find (e.g. on Ubuntu) you can use -delete:

find . \( -name '._*' -o -name '.DS_Store' \) -delete

]]>
http://postpostmodern.com/2009/06/08/terminal-tip-delete-those-mac-dot-files/feed/ 4
Leopard-Style iTerm Icon, Take 2 http://postpostmodern.com/2008/12/18/leopard-style-iterm-icon-take-2/ http://postpostmodern.com/2008/12/18/leopard-style-iterm-icon-take-2/#comments Fri, 19 Dec 2008 01:56:11 +0000 Jason Johnson http://postpostmodern.com/?p=279 Several days ago, I posted a suggestion for a new icon for iTerm, a terminal app that many developers prefer over the standard Terminal app. The first version was just a few standard Leopard icons thrown together. A few days later, I updated the icon with a more balanced, albeit less-colorful, version featuring a vectory globe.

At the developers’ request, I have updated it once again. The color has been brought back to the globe, and the smaller versions (32px and 16px) have been simplified a bit for a cleaner appearance. I encourage you to try the new version. You can click it to download the .icns file, which may be placed inside iTerm.app/Contents/Resources. Enjoy.

iTerm Icon

]]>
http://postpostmodern.com/2008/12/18/leopard-style-iterm-icon-take-2/feed/ 8
Leopard-Style iTerm Icon http://postpostmodern.com/2008/12/05/leopard-style-iterm-icon/ http://postpostmodern.com/2008/12/05/leopard-style-iterm-icon/#comments Sat, 06 Dec 2008 03:28:12 +0000 Jason Johnson http://postpostmodern.com/?p=251 This article has been superceded. See here.

Speaking of iTerm, isn’t it about time we had an updated icon? I’ve cobbled one together using bits of the Terminal icon with elements from the previous iTerm icons. Not exactly original. Same concept as the old icon. It’s just more Leopardy now. Click it to download the .icns file. I recommend downloading the revised version below.

iTerm Icon

Let me know what you think.

Update – Dec 7

Here is an updated version that’s a little more balanced, and looks better at small sizes. Click it to download the .icns file.

Gray iTerm Icon
]]>
http://postpostmodern.com/2008/12/05/leopard-style-iterm-icon/feed/ 6
More Usable Mac: Finder Toolbar http://postpostmodern.com/2008/12/05/more-usable-mac-finder-toolbar/ http://postpostmodern.com/2008/12/05/more-usable-mac-finder-toolbar/#comments Fri, 05 Dec 2008 22:29:31 +0000 Jason Johnson http://postpostmodern.com/?p=235 I’ve been meaning to write a few short posts about how I use my Mac. I think it would be helpful for everyone if we knew more about the way others work. This is the first. Please share your tips in the comments.

What’s in your Finder toolbar?

I find it useful to keep a few extra items in my Finder toolbar. Anything to which you would drag files and folders would be appropriate to put in your Finder toolbar. Here’s mine:

Finder Toolbar

From left to right:

  1. Path Button is one of those buttons that is not in the default set. It’s pretty handy, though. You can click it to see a list of the parent folders for upward navigation. I’ve recently discovered you can get the same functionality by right-clicking on the name of the folder in the title bar. So, I might remove the path button.
  2. CleanArchiver is an essential app for creating clean zip (or gzip, bzip, Disk Image, etc) files without the pesky .DS_Store files. Every time I need to send a zip file to a Windows user, I just drag the file to this icon. You can find CleanArchiver at Sopht Square.
  3. TextMate, everybody’s favorite text editor, is handy to have here because you can drag a folder to open a project.
  4. Transmit is a nice SFTP app that has a feature called ‘Dock Send’ which allows you to upload files to certain places based on the location of the file on your computer. Just drag the file to its dock icon (or, in this case, it’s toolbar icon).
  5. Transmit Droplets allow you to upload files to a specific server directory.
  6. AppZapper is a popular app for removing applications including all related files.

That’s about it for my Finder toolbar. What’s in yours?

Update

I’ve merged Trey’s buttons into my toolbar. But, instead of ‘Open in Terminal’, mine is ‘Open in iTerm’, using this script and henrik’s icon.

I should also mention that I keep a divider between any icons to which I drag files/folders so I don’t accidentally drop on the wrong icon. And AppZapper stays well away from everything else.

The Result:

Finder Toolbar v2
]]>
http://postpostmodern.com/2008/12/05/more-usable-mac-finder-toolbar/feed/ 3
A Smarter MAMP http://postpostmodern.com/2008/10/22/a-smarter-mamp/ http://postpostmodern.com/2008/10/22/a-smarter-mamp/#comments Wed, 22 Oct 2008 16:08:44 +0000 Jason Johnson http://postpostmodern.com/?p=170 This past weekend, I was cleaning up my ~/Sites folder, and I started thinking, “There’s got to be a better way!” And I wasn’t referring to baby hammock. I was talking about having to set up all those virtual hosts and whatnot. Well, a little research quickly brought me to the “how did I not know this before?!” point. And now, I will share it with you.

(Editor’s Note: This article turned out to be a little longer than I expected. The whole process is really quite simple. It should only take about 10 minutes, at the most.)

The first thing I didn’t realize is that Apache supports something called dynamic virtual hosts. That means you don’t have to create a virtual host in your conf files and restart Apache every time you want to create a new site. This is incredibly handy for development. Combine that with a real DNS server (BIND), and you have a much smarter system. I can now create a whole new site on my MacBook just by creating a new folder! Much simpler than the old way.

The Old Way?

To put this in context, let’s quickly review the old way. For years, I’ve developed websites on Mac OS X using the standard ‘MAMP’ setup: Mac/Apache/MySQL/PHP. When starting a new site, the first thing I do is set up a virtual host for Apache. If you’re like me, you know this as a 4-step process:

  1. Create a directory for the site’s files. Something like:

    mkdir -p ~/Sites/domain.com/public

  2. Create a line in /etc/hosts for the domain:

    127.0.0.1 domain.dev

  3. Add a few lines to my Apache conf file to configure the virtual host:

    <VirtualHost *>
      ServerName domain.dev
      DocumentRoot /Users/jason/Sites/domain.com/public
    </VirtualHost>
    
  4. Restart Apache:

    sudo apachectl graceful

The New Way!

  1. Create a directory for the site’s files. Something like:

    mkdir -p ~/Sites/domain.com/public

Done.

Not only that, but I also decided to set up a few TLDs to separate my sites. I use .ppm for my personal and freelance sites, .dev for my experimental stuff, and .bsi for my company work. This allows me to separate sites like so:

Sites
|-- bsi
|   |-- this
|   |-- that
|   `-- theother
|-- dev
|   |-- experiment1
|   |-- experiment2
|   |-- youget
|   `-- thepoint
`-- ppm
    |-- postpostmodern
    `-- littlebeestudio

These would be:

  • this.bsi
  • that.bsi
  • theother.bsi
  • postpostmodern.ppm
  • littlebeestudio.ppm
  • experiment1.dev
  • experiment2.dev
  • youget.dev
  • thepoint.dev

First, let’s talk about the hosts file.

The first thing you need for an Apache virtual host is a unique hostname. As can be seen in step 2, above, this is usually accomplished via the /etc/hosts file. The only problem is the hosts file doesn’t support any wildcards. So, you can’t say:

127.0.0.1    *.dev

Instead, you have to have this:

127.0.0.1    postpostmodern.dev
127.0.0.1    littlebeestudio.dev
...
...

…and eventually, you end up with a hosts file a mile long.

Enter BIND — the built-in, but inactive DNS server

BIND (named) comes with Mac OS X. We just need to configure it and turn it on.

I should mention here that DNS server stuff falls outside of my comfort zone. I just followed a few articles (on macosxhints and Ubuntu Forums) to get this working. I’m not sure how it impacts the vulnerability of your Mac from a security standpoint. All I know is that it works and provides a few advantages over the hosts file:

  • You can set up TLDs to resolve to your local IP address. So, anything.dev and anything.test will automatically stay local.
  • Apparently, since BIND will be caching DNS info, it will make web browsing faster. I haven’t formally tested this, but if it’s true, it’s a nice bonus. It does seem a little quicker.

Setting up rndc

This creates a configuration file and key for rndc, which controls named.

Get into sudo, and make it stick.

sudo -s

Generate the conf file.

rndc-confgen > /etc/rndc.conf

Copy the key to the key file.

head -n 6 /etc/rndc.conf > /etc/rndc.key

Exit sudo.

exit

Creating your DNS zone files

DNS zones are created via files in /var/named. Create a new file in there called dev.zone and fill it with this:

;
; BIND data file for dev sites
;
$TTL    604800
@       IN      SOA     dev. root.dev. (
                     2008101920         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      dev.
@       IN      A       127.0.0.1
*.dev.  14400   IN      A       127.0.0.1

Repeat the above for each TLD you want to set up, replacing ‘dev’ of course.

Configuring named.conf

Now, open /etc/named.conf. The first thing you want to do here is to show named where to get its DNS info (for the rest of the internet), i.e. forwarding servers. Let’s use OpenDNS. Add these lines in the options section of named.conf (after ‘directory “/var/named”;’):

forwarders {
    208.67.222.222;
    208.67.220.220;
};

Now, we just need to let named know about those zone files we created a minute ago. For each of the zone files, create a section like this:

zone "dev" IN {
  type master;
  file "dev.zone";
};

You’ll see where to put it. There’s a ‘localhost’ section already there. Just put yours below that.

Configuring and loading the LaunchDaemon

Okay. One last thing. Tell Mac OS X to activate named. Open the LaunchDaemon plist file for named (I had to use Textmate because Property List Editor didn’t let me save a file belonging to root.):

/System/Library/LaunchDaemons/org.isc.named.plist

Change ‘disabled’ from true to false, and save the file.

Now, load it:

sudo launchctl load /System/Library/LaunchDaemons/org.isc.named.plist

If everything went well, your DNS server should be up and running, and your personalized TLDs should resolve to your local machine. Try visiting something.dev and see if it resolves correctly. You might want to comment out all those custom lines from your /etc/hosts file too.

Now for the Apache Magic!

Now that the DNS stuff is out of the way, it’s just a matter of setting that magic directive in your Apache conf file. The directive is called VirtualDocumentRoot.

I don’t know how you have your Apache configured, but personally, I like to keep all of my custom configuration in my own file (the one in /etc/apache2/users). Here is what my /etc/apache2/users/jason.conf file looks like:

DocumentRoot "/Users/jason/Sites/default/public/"

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
    VirtualDocumentRoot /Users/jason/Sites/%-1/%-2+/public
</VirtualHost>

The DocumentRoot directive is for the default site — the site that comes up when you visit http://localhost. The NameVirtualHost should be the reverse IP for your local machine. Finally, the VirtualDocumentRoot is an interpolated path for finding your sites. ‘%-1’ means the last part of the domain name (the TLD). ‘%-2+’ means everything before that. So, http://example.dev/ would load files from /Users/jason/Sites/dev/example/public. If you want a different scheme, read more about directory name interpolation on Apache’s web site.

Now, restart Apache!

sudo apachectl graceful

You should be good to go!

Please let me know your thoughts and corrections in the comments.

Update – 28 Oct, 2008

As Brian Toth mentioned in the comments, it’s probably also necessary to add 127.0.0.1 in your DNS settings in the Network System Pref pane.

]]>
http://postpostmodern.com/2008/10/22/a-smarter-mamp/feed/ 57
Screenwatcher http://postpostmodern.com/2006/11/19/screenwatcher/ http://postpostmodern.com/2006/11/19/screenwatcher/#comments Mon, 20 Nov 2006 02:32:55 +0000 Jason Johnson http://blog.postpostmodern.com/2006/11/19/screenwatcher-a-visual-activity-log/ Sometimes I end up asking these questions:

  • How many hours did I spend on that project yesterday?
  • What day did I work on x project?
  • Where did the time go today?

I’m not the best at recording my time as I work on stuff. And I’ve never found the perfect time-logging application, anyway. So, the answers to these questions usually come from tedious review of file modification dates and emails. I can usually put together most of the pieces of the past week’s activities, but it’s a real pain in the ass, and the result is not very accurate.

The other day, I said to myself:

“Self, can’t your Mac automatically keep track of what I do in an easy-to-understand format?”

“Of course it can!” I replied. “How about something that produces a visual activity log where you can see what you were doing every 15 minutes of every day?”

“Excellent!! We’ll call him Screenwatcher.”

How? Simple: 3 steps!

  1. Create a folder in which to put your screenshots.
  2. Write a script that takes a screenshot and saves it in the aforementioned screenshots folder.
  3. Have the computer run the script every 15 minutes.

On Mac OS X 10.4, this involves a shell script and a plist for launchd. It’s easier than it sounds.

Step 1: Create the Folder

I created a folder in my home directory called ‘Screenwatcher.’ i.e. ~/Screenwatcher

This folder will automatically get subfolders for each day. The shell script handles that. Which brings us to…

Step 2: Create the Script

The shell script looks like this (replace “jason” with your username):


#!/bin/bash
# Change to a Screenwatcher directory in your home directory
cd /Users/jason/Screenwatcher
# Make a directory based on the date
mkdir -p `date "+%Y-%m-%d"`
# Capture
screencapture -C `date "+%Y-%m-%d"`/`date "+%H.%M"`.png

I saved this script here: ~/Library/Scripts/Shell/screenwatcher.sh

UPDATE: Don’t forget to give it execute permissions:

chmod 755 ~/Library/Scripts/Shell/screenwatcher.sh

Step 3: Create the launchd plist

Launchd is a part of OS X that runs tasks at specific times and/or intervals. Plist files tell Launchd what to run and when to run it.

The screenwatcher plist looks like this1:


<?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.postpostmodern.screenwatcher</string>
  <key>LowPriorityIO</key>
  <true/>
  <key>Program</key>
  <string>/Users/jason/Library/Scripts/Shell/screenwatcher.sh</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/jason/Library/Scripts/Shell/screenwatcher.sh</string>
  </array>
  <key>ServiceDescription</key>
  <string>Takes a picture of the screen every 15 minutes</string>
  <key>StartInterval</key>
  <integer>900</integer>
</dict>
</plist>

The StartInterval is in seconds. Change it to whatever you want. I track my time in 15 minute increments; so, 900 seconds does me just fine. If I had vast amounts of disk space, I might get crazy and try 300.

This plist needs to be saved in ~/Library/LaunchAgents (e.g. ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist). If your LaunchAgents folder doesn’t exist, create it.

Placing the plist file in the LaunchAgents folder allows launchd to automatically find it when you log in. You can also manually load it via this command:

launchctl load ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist

Get me off this crazy thing!

How do you stop it? This will unload it from launchd:

launchctl unload ~/Library/LaunchAgents/com.postpostmodern.screenwatcher.plist

And removing the plist from the LaunchAgents folder will keep it from being loaded next time you log in.

Final Notes

Now that all of this is up and running, you can focus on your work and know that your good ol’ Mac is keeping an eye on you. How do you know? You’ll hear the little shutter sound. If the shutter sound gets too annoying you can alter the shell script and add the -x flag to the screencapture command. But I like the sound. It reminds me that it’s doing its job.

I should also mention that the reason I keep my shell scripts in my ~/Library/Scripts folder is so it will show up in my Scripts Menu. That way, I can manually take a Screenwatcher screen capture whenever I want.

Finally, don’t forget to clean out your Screenwatcher folder every once in a while. The PNGs don’t take up a ton of space, but they take up enough. I don’t like to keep more than a few days. You could modify the script to handle the file deletion, but I prefer to do it manually.

UPDATE:

It has come to my attention that OS X 10.4.7 introduced a launchd/launchctl bug that causes this: “Workaround Bonjour: Unknown error: 0”. I haven’t seen this myself (some say it’s fixed on the Intel version of 10.4.8), but it has been confirmed to happen on a G4 PowerBook. Most Google results say that it doesn’t cause too much trouble. And I think it’s only when you run launchctl. I don’t think that it will happen when you restart.


  1. I actually didn’t write the plist file by hand. There’s an application called Launchd Editor that does it via a GUI. If you want to make more launchd plists, you might want to download it. ↑ back up there
]]>
http://postpostmodern.com/2006/11/19/screenwatcher/feed/ 5
2 Degrees of Pandora http://postpostmodern.com/2006/09/26/2-degrees-of-pandora/ http://postpostmodern.com/2006/09/26/2-degrees-of-pandora/#comments Wed, 27 Sep 2006 01:17:47 +0000 Jason Johnson http://blog.postpostmodern.com/2006/09/26/2-degrees-of-pandora/ De Novo Dahl — Cats & Kittens I just wanted to say that it was pretty cool that Pandora a) has De Novo Dahl’s Cats and Kittens in their catalog and 2) thinks I’d like them.

Of course, I do love the De Novo Dahl. They are a great band and a great bunch of guys/girl.

And as a side note — if you have a Mac and like Pandora, you should try PandoraBoy. It’s a good free app with a stupid name that plays Pandora without a browser. That’s not the good part though. It will also let you control Pandora (including like/dislike) with the Apple Remote, and posts notifications to Growl. So, now I can hook the ol’ MacBook up to the stereo and listen to Pandora radio around the house. I also created a giant Growl display style so I can read it from across the room.

]]>
http://postpostmodern.com/2006/09/26/2-degrees-of-pandora/feed/ 0
Synk, SuperDuper! Alright http://postpostmodern.com/2006/01/23/synk-superduper-alright/ http://postpostmodern.com/2006/01/23/synk-superduper-alright/#comments Mon, 23 Jan 2006 06:36:18 +0000 Jason Johnson http://www.postpostmodern.com/2006/01/23/synk-superduper-alright/ So, Trey convinced me to try SuperDuper!. I like it. It’s extremely easy-to-use and quick to operate. It’s very similar to Synk. Synk actually has a few more features for regular backups; plus, it’s a tad cheaper. It’s kind of a tough decision.

One thing that they both feature is an option to run a shell script. Or, in the case of Synk, any file. before it does its backup thing. Since I don’t have enough room on my external, I just do a “User Files” backup. That shell script feature comes in handy because I can mysqldump all of my databases to files and also get a list of my installed applications saved to my Documents folder immediately before the backup.

ls -al /Applications > ~/Documents/Application\ List.txt

Very handy.

]]>
http://postpostmodern.com/2006/01/23/synk-superduper-alright/feed/ 11
Find/Replace in Selected Files http://postpostmodern.com/2006/01/06/findreplace-in-selected-files/ http://postpostmodern.com/2006/01/06/findreplace-in-selected-files/#comments Fri, 06 Jan 2006 22:29:21 +0000 Jason Johnson http://www.postpostmodern.com/2006/01/06/findreplace-in-selected-files/ I was planning on posting some nice friendly post before getting into technical stuff, but Trey really wants me to post this. So, here’s a TextMate tip.

So, there you are, working on a project in TextMate. You have a project full of a gazillion files. Then, you notice that some text that appears in several files needs to be changed. You need to do a find/replace in those files, but you don’t want to do a “find in project” because it’ll take forever to go through all those files and change only the ones you want.

  1. Select the files you want to change.
  2. Drag them to the TextMate icon in the dock.
  3. Do a Find in Project.
  4. Save all files in project.
  5. Close the temporary project w/o saving.

The files I need to change are usually all in one folder. So, it’s really easy to drag a folder to the TextMate dock icon, do the stuff, and close.

]]>
http://postpostmodern.com/2006/01/06/findreplace-in-selected-files/feed/ 1