OS X

Move your OS X Server Documents out of /Library and backup with Backblaze [solved]

As a web developer, the easiest thing for me to develop on my mac was to work from /Library/WebServer/Documents, which is the default directory for OS X’s apache. There are two problems with this: First, the permissions are all root. I found it easiest to change Documents’ owner to my user, but then running a permissions repair would automatically change these back. Second, Backblaze automatically excludes your /Library directory, so none of my web work was getting automatically backed up. I contacted backblaze about including only this directory and got this response:

I am sorry but there is not a way to back up this data.
Backblaze does not back up the system files or the system library. The /Library and all subdirectories are excluded.

My solution was to create a new directory, webdocs, in my home folder, and to move everything that was in /Library/WebServer/Documents into it. Then, I edited /etc/apache2/httpd.conf with root privileges (in terminal: sudo nano /etc/apache2/httpd.conf or sudo edit /etc/apache2/httpd.conf or sudo subl /etc/apache2/httpd.conf depending on your text editor of choice), and replaced all instances of /Library/WebServer/Documents with /Users/jordan/webdocs. Then I ran sudo apachectl restart to restart apache. Now all of my web work will get backed up automatically by backblaze.

Install php-libevent on OS X [solved]

I’m experimenting with Ratchet, a websocket server written in PHP. I wanted to install lib-event for PHP because according to this thread it works better than PHP’s choose_stream function. It ended up being a pain: port install libevent worked but when I ran pecl install channel://pecl.php.net/libevent-0.0.5 it could not find the libevent headers even when I pointed it to /opt/local/lib/, which is where port contents libevent said it was installed.

I ended up following this tutorial on compiling it from source and then pointing the pecl installer to that library and it worked. Mostly. Compiling it from source put it in /usr/local/lib, which the pecl installer liked better. Then it was a question of enabling it in PHP.

OS X’s php.ini installed here:

/etc/apache2/php.ini

MacPort’s PHP is installed here:

/opt/local/etc/php5/php.ini

Unless you change your default setup, apache will serve pages with OS X’s PHP, while the command line will serve pages with MacPort’s PHP.

Most of my OS X PHP extensions are installed here:

/usr/lib/php/extensions/no-debug-non-zts-20090626

Most of my Mac Port PHP extensions are installed here:

/opt/local/lib/php/extensions/no-debug-non-zts-20090626

I had to copy libevent.so from my mac’s extension directory to the macports extension directory, and add extension=libevent.so to both php.ini files.

ReFit hangs on windows logo [Solved]

My ReFit was hanging on the windows logo on my macbook pro when I would boot into windows.

I was having problems with windows explorer crashing every 5 seconds anyway so I plugged in my boot thumbdrive and reset (reformatted) windows.

However, refit would STILL hang on the windows logo even after a clean install. If I held down option when booting I could use Apple’s menu to get to Windows, but not via Refit.

Finally, I tried unplugging everything from my macbook, including the external mouse, SD card, and external monitor.

Now it boots fine! Hopefully this saves someone from reformatting like I did when it was just a hardware conflict. I have read other reports of USB hubs and other peripherals also causing refit to hang.

Free Create Shadow Action in Photoshop

I have created a Photoshop action to automatically generate a shadow for a given png. I recommend extending the canvas right 10 or so pixels first. It expects the file to have a single layer with transparency. It duplicates the layer, adds a black color overlay, rasterizes the layer effect, squishes the layer with free transform, skews it to the right, puts the layer below the first one, sets the opacity to 57%, and hides the first layer.
This is useful for generating custom pin shadows for leaflet, google maps or bing.
Create Shadow.atn
On mac you can place this in: ~/Library/Application Support/Adobe/Adobe Photoshop CS6/Presets/Actions/

Disable OS X Lion’s “is an Application Downloaded from the Internet. Are you sure you want to open it?” message with Onyx [solved]

What a Vista-like message. Apple warns you every time you open almost any kind of file that was downloaded from the internet, which is MOST files these days. There doesn’t seem to be any way to turn it off. It happens with applications, php files, even HTML and jpg files. As a PHP programmer, I can’t stand seeing this message every time I open files that I coded MYSELF. It severely interrupts my workflow.

The commonly suggested method of using terminal to write to defaults does NOT work for me:
defaults write com.apple.LaunchServices LSQuarantine -bool NO

There is another method of manually removing the quarantine flag of the files that you download each time you download them, but this would take more time than just clicking ok in the stupid dialog.

What did work for me was downloading the latest version of Onyx and unchecking the internet warning checkbox. Thank you, Titanium Software!

Note that this does make your computer more susceptible to viruses and trojans if you visit risky sites or blindly open unknown applications. For users like me, this is preferable to the condescending, interrupting workflow Apple has been increasingly favoring lately.

Cancel or Allow?

Don’t Run Two Instances of TextWrangler at Once [Solved]

Update:Barebones support got back to me and explained why this wasn’t working, this method broke their codesigning. But they had a solution: Simply go to File > New > FTP/SFTP Browser. Thanks Barebones!


Edit: Darn, I’m getting this error when trying to open remote documents: (MacOS Error code: -25293)

When I’m working on two projects at once, or want to grab a remote file from FTP when I already have one FTP site open, it would be nice to run two instances of TextWrangler at once, since it only supports having one FTP site open at a time.

I figured out how:

-Go to Applications/ and right click on TextWrangler and select Duplicate.
-Rename Textwrangler copy to Textwrangler2
-Right click on Textwrangler and choose “Show Package Contents”
-Open info.plist inside the Contents folder
-Change the data from

	<key>CFBundleIdentifier</key>
	<string>com.barebones.textwrangler</string>



to

	<key>CFBundleIdentifier<</key>
	<string>com.barebones.textwrangler2</string>



Now you can open both TextWrangler apps.


Optionally, grab this snazzy textwrangler alternative icon from this page:
http://sethlilly.deviantart.com/art/TextWrangler-Replacement-Icon-180898652
Right click and choose "copy image". Then get info on TextWrangler2, click on the small icon in the top right, and hit command-V to paste. That way it's easy to tell the two instances apart in the Dock and switching between applications.

How to update Jailbroken iPhone to 4.3.3 [solved]

After having some problems with my home button, I tried taking my iPhone to the Apple store, who told me it would cost $200 to replace the hardware button on my iPhone. They also mentioned there were some home button issues with 4.3.1, the version of my iPhone OS, and to try updating. (They also said they had to mention the jailbreak could be my problem and to remove it).

I went home, determined to either fix the home button myself (they cost $5 online) or try a software update. I tried updating to 4.3.3 first, the latest untethered jailbreak. This is trickier now that 4.3.5 is out.

First, I ran AptBackup, a package you can find in Cydia to save all of your jailbroken apps for restoring later. (Edit: AptBackup deleted all my AppStore apps, people recommend PkgBackup instead.) I also saved my SHSH blobs in Cydia (important) when it prompted me, so that I could upgrade or downgrade my iOS freely.

I downloaded iOS 4.3.3 from here and tried option-updating or option-restoring in Itunes, but it gave me the error “The device isn’t eligible for the requested build.” I learned this is because Apple stopped signing iOS 4.3.3 in an effort to prevent jailbreaking.

I followed Saurik’s old guide, adding the line “74.208.10.249 gs.apple.com” to my /etc/hosts file to have Saurik’s Cydia server spoof apple’s verification servers. This bypasses the “eligible” error in iTunes, but as described, at the end of the restore I got the error message The iPhone “iPhone” could not be restored. An unknown error occured (1015)” Saurik writes that you should restore twice, but that you will get this message both times and get stuck in recovery mode, and then you should jailbreak.

Then, I tried using the latest version of RedSn0w to jailbreak. RedSn0w requires you to enter DFU mode by turning off the phone, but in recovery mode the phone turns on automatically when it’s plugged into USB. Regardless, I was able to enter DFU mode by holding down power for 2 seconds, pressing the power and home button for 10 seconds, and then releasing the power button and holding home for 10 seconds. Then, the phone hung on the “Installing Activation Bundles” screen and then rebooted and was stuck on the recovery screen.

I tried the application “fixrecovery43” but it didn’t work. (I got the error: libusb:error [darwin_transfer_status] transfer error: timed out)

What did work for me was installing TinyUmbrella and clicking the “Exit Recovery” option. TinyUmbrella crashed a few times on me, I think because of conflicts with Apple’s httpd server. I had to disable websharing and type “sudo killall httpd” in Terminal first. Then I clicked TinyUmbrella’s “Start TSS Server” and then it ran better. Open up /Applications/Utilities/Console.app for more details on what’s happening if you’re having trouble with TinyUmbrella. Evidentially you can use their TSS servers to restore the phone via iTunes as well but it didn’t work for me (I got a “could not connect to apple servers” error in iTunes).

Note: TinyUmbrella edits your hosts file and deletes everything except the gs.apple.com line. If you have other lines in your hosts file I suggest backing it up.

First I tried DFU mode, but the “fix restore” button didn’t work (the phone got stuck on a greenpois0n screen with the message “unable to find gbdevlist” and “unable to find fs_mount”). What worked for me was leaving the iPhone in recovery mode (iPhone screen on, usb cable icon pointing to iTunes icon), and then it shows up in the list of devices in recovery mode. Then I simply clicked on “exit recovery” and my phone booted normally into 4.3.3. Whew!

Finally, I reinstalled AptBackup and clicked “restore”, which restored all of my Cydia apps, but deleted all of my appstore apps. None of the suggested online fixes (installing an appstore app, resyncing with iTunes, turning on and off restrictions) worked. People online recommend PkgBackup instead of AptBackup, note to self. Anyway I restored my apps and settings from backup again using my old backup in iTunes and all is good. So far so good with the home button. If your iPhone 4 home button is still on the fritz, there are some good voodoo tricks in the comments here.

Create an encrypted folder with OS X Disk Utility [Solved]

I run several servers on my mac, and worry about getting hacked or accidentally sharing sensitive files. In addition, I worry about sensitive files when I take the computer in for tech support, or when others use my computer. Documents such as my tax files contain my social security number.

I don’t have to worry any longer (until AES is cracked, anyway), because it is easy to create an encrypted disk image on OS X. I followed the instructions here:

http://blog.smalldog.com/article/1814/use-disk-utility-to-encrypt-files/

I chose a 2.5 GB image, which automatically suggested a CD/DVD type partition. I’m not sure what partition type to use but don’t think it matters. These were the settings I used:

This will create a .sparseimage file. Sparse images are nice because they don’t actually take up their entire hard drive space until they’re filled with contents.

Note that after you drag the files in, you still have to delete the originals. Then when you eject the encrypted image, they are protected. When you double click on the image again, it will ask you for your password. Don’t forget this password, because it is impossible to recover!

I used spotlight to search my computer for files containing my passwords or social security number. If they were necessary, I dragged them in here, otherwise I deleted them.

SMSDaemon crash causes screen to wake up and hard drive to constantly access [Solved]

I have been having issues with my Mac screen waking up in the middle of the night for some years now. I think I may have finally solved it. Many sites have suggested that a faulty USB bus or oversensitive USB mouse could cause the wakeup, but I ruled that out when I migrated my OS to a new mac with new hardware. It had to be software related.
My solution is probably very uncommon, but perhaps the diagnostic steps I took would be useful to others.
I woke up at 5:57 AM to my mac screen turning on and my hard drive accessing constantly. I’ve written a script that can sleep my display from my phone, but instead of doing that I got up and started investigating.
I launched Console (Applications/Utilities) and took a look at the Console Messages log. At 5:52 AM there was a ReportCrash that said “Saved crash report for SMSDaemon” and a path to the crash file.
I googled “SMSDaemon OS X crash” and came across a macrumors thread that explained that it is an open source daemon installed by the Syphone utility, a piece of software that used to help get text messages off your iphone but is no longer supported. That thread didn’t have a lot of info on how to remove syphone though, so a google search of “uninstall syphone” lead me to this page, which has the following instructions:

1) Launch Syphone, open the Preferences, and UNcheck “Run helper app in the background” (leave it unchecked if it already is).

2) Close Syphone.

3) Go into ~/Library/Application Support/ and delete the folder named ‘Syphone’.

4) Go into ~/Library/Preferences/ and delete the file named ‘com.micromat.Syphone.plist’.

The Syphone application now just displays a link to techtool pro, but you can still access the preferences menu and turn off the Daemon. If you can’t run Syphone for some reason, the following commands will unload the daemon and delete it:

$ launchctl unload ~/Library/LaunchAgents/com.micromat.SMSDaemon.plist
$ rm ~/Library/LaunchAgents/com.micromat.SMSDaemon.plist

Apparently SMSDaemon may have had an enormous memory leak; I’ve come to my computer with 1.5 TB free and yet gotten the “there is no more disk space on the startup disk to write, please force quit some applications” errors before. Others have complained of memory leaks too; my machine seems to be running better now.

Override USB or Firewire Volume Level in OS X with Soundflowerbed [solved]

Update2: Lion has this functionality built-in. hurray!

Edit: While the sound controls work, I’ve been having major issues with soundflower, from audio disappearing to getting stuck and looping on a sample. Looks like soundflower still needs a bit of development. :(

This has been driving me nuts for years.

I have an external firewire audio interface, a MOTU 896, that has served me well for 7 years. It powers my studio monitors, has multi inputs and delivers superior sound compared to my internal computer speakers.

The only problem with it is that OS X’s volume controls don’t work with it. The volume keys don’t work on the keyboard, the apple remote volume doesn’t work, and you can’t control the volume with AirMouse on the iPhone. In system preferences, you get the message “The selected device has no output controls”, and you get an annoying disabled speaker when you try and use the volume controls.

Thanks to this post and the wonderful folks at Cycling 74, there is a free solution. You can install soundflower, which allows you to route all of your audio to a soundflower device. Once you’ve installed soundflower, you can run Soundflowerbed from your applications menu, which makes a finder menu appear that allows you to choose which device to route audio to. Choose your external device, and you’re done!

Finally, you can leave the volume knob on your external device in one setting, and control the volume from across the room with a remote! Glorious!

Soundflower is also a great app for interapplication multichannel audio routing, similar to rewire or jack.

Next »