Archive for September 13, 2013

Friday, September 13, 2013

RegEx Knife

Mark Alldritt:

RegEx Knife is a port of the Regular Expressions Tester functionality from Affrus 2 to the iPad. This tool allows you to enter regular expressions into a syntax highlighted editor, enter sample text against which the regular expression is matched, and finally, enter a substitution template which is used to transform the sample text.

Looks great, although the idea of typing regular expressions on the iPad keyboard makes me want to run for the hills.

Update (2014-07-17): The app now available in the App Store.

Mac Dropping the Wi-Fi Connection

Starting in the late spring or early summer, my main MacBook Pro started losing its Wi-Fi connection to the AirPort Extreme Base Station (fifth generation) several times per day. Instead of five black signal strength bars in the menu bar, I would suddenly see five gray ones. This seemed to happen most often while the Mac was doing an unattended Arq backup. I could always re-select my network from the menu, and it would instantly connect again with full signal strength. It would never auto-reconnect, however. The problem never affected other computers or iOS devices, even ones the same 35-foot distance from the base station.

I saw Console messages like this:

9/9/13 12:01:14.000 AM kernel[0]: MacAuthEvent en0   Auth result for: 70:73:cb:bb:ae:47  MAC AUTH succeeded
9/9/13 12:01:14.000 AM kernel[0]: wlEvent: en0 en0 Link UP virtIf = 0
9/9/13 12:01:14.000 AM kernel[0]: wl0: Roamed or switched channel, reason #8, bssid 70:73:cb:bb:ae:47
9/9/13 12:01:14.000 AM kernel[0]: en0: BSSID changed to 70:73:cb:bb:ae:47
9/9/13 12:01:14.000 AM kernel[0]: en0::IO80211Interface::postMessage bssid changed
9/9/13 12:01:17.000 AM kernel[0]: wlEvent: en0 en0 Link DOWN virtIf = 0
9/9/13 12:01:17.000 AM kernel[0]: AirPort: Link Down on en0. Reason 2 (Previous authentication no longer valid).

Searching the Apple discussion forums, people have been reporting symptoms like this (probably with different causes) since since Lion, if not earlier.

I found a potential workaround in that there’s a command-line tool that can check whether Wi-Fi is active:

networksetup -getairportpower en0
Wi-Fi Power (en0): On

Which means that it should be easy to write a cron job that re-enables it if necessary:

networksetup -setairportpower en0 on

That could be my backup plan, but I wanted to actually fix this. I called AppleCare, and the specialist walked me though some basic troubleshooting steps: resetting the SMC, resetting the PRAM, doing a safe boot, and resetting the base station. He then got some more specialized information. I was told that:

  1. In the Network preferences, “Require administrator authorization to: Turn Wi-Fi on or off” should be checked. I had thought that this was for when the user turns it off, but the wireless specialist said that it also prevents the Mac from turning off the Wi-Fi chip due to inactivity.
  2. In the Energy Saver preferences, “Wake for Wi-Fi network access” should be checked. I had thought this was for waking the Mac from sleep, but the wireless specialist said that this prevents the Mac from putting the wireless card to sleep, which it tries to do even when the Mac is plugged in and set never to go to sleep.

I was skeptical about this advice, but I tried it. It didn’t help.

It was then suggested that I run Wireless Diagnostics by holding down the Option key and choosing it from the AirPort menu. I had done this before, and it found no problems. However, rather than immediately seeing the report, you can choose the option to “Monitor my Wi-Fi connection.” It will then keep running in the background. When there’s a problem with the connection, it will bounce its Dock icon, write a lot of log files to the desktop (reminiscent of sysdiagnose), and present some recommendations.

In my case, one of the suggestions was to use a dual-band wireless router (which I already had). Another was that the 5GHz band is typically less susceptible to interference from other devices than the 2.4GHz band. I had been using the standard configuration in AirPort Utility with the both the 2.4Ghz and 5GHz channels set to Automatic. On this advice, I checked the box to specify a separate “5Ghz network name,” so that the Mac doesn’t try to connect at 2.4Ghz. After selecting this network in the AirPort menu, the Mac has been reliably connected to the network ever since. (With Wireless Diagnostics running in the background, it has detected several disconnections, but it is apparently reconnecting automatically and immediately so that this is not noticeable.)

Wireless Diagnostics: Crowded Wi-Fi Channel Wireless Diagnostics: Poor Wi-Fi Environment

Playing Sound Effects the Right Way

Paul Kafasis:

Unfortunately, many applications do not currently play their sound effects properly, ignoring the user’s Sound Effects output selection. The end result for users is that audio snippets which are in fact sound effects incorrectly play through the main audio output. Luckily, fixing the problem is quite simple. Below, we show example code for playing back audio with Cocoa’s NSSound, on the system alert device.

Their code sets the device playback identifier on an NSSound, which you can then play in the normal way. I found that this correctly plays the sound on the right device, but it does not respect the “Alert volume” in System Preferences. For SpamSieve, I have been using the AudioServicesPlayAlertSound() API, which uses both the alert device and the alert volume.

iPhone Photography

Federico Viticci:

The Camera app’s 5s-only features are worth a mention as well. With the 5s’ A7 chip, iOS 7 can automatically adjust the camera’s white balance and exposure, run algorithms to pick the best shot out of multiple ones that were actually taken behind the scenes upon pressing the shutter button, and provide automatic image stabilization without the user ever knowing what’s going on with the CPU, optics, and camera software. When all the pieces are combined, the user knows that the iPhone 5s can take slow-motion videos, shoot up to 10 photos per second, make people’s faces more natural when the flash is on, remove shakiness, and zoom on live video. Behind the scenes? iOS 7, the A7, and the camera sensor work in tandem to capture more light, process information such as closed eyes and movements, and then present it through the interface. When using an iPhone, the user only knows that the 5s takes better photos with cool new features.

Justin Williams:

All I know is that for everything that Android and Google are getting right these days, they still haven’t gotten close to touching Apple in the area that is of utmost importance to me: photo quality.

Here’s Apple’s iPhone 5s photo gallery.

Update (2013-09-24): Dean Holland (via John Gruber):

In a break with previous iPhones, you can’t press-and-hold to focus in advance. The 5S shoots when you press the on-screen button, not when you release it. You can still use either of the volume buttons on the phone to shoot, or the volume buttons on the earphones as a remote control/cable-release. I like the new way - it feels much more responsive, but I have to be careful of wobbling the camera in low light.


But I’d argue that technical innovation is not what this phone is about. I’ve found the iPhone 5S to be the most fun iPhone camera to date. Instead of extra pixels, I’m enjoying the speed, performance, and the new party tricks of burst shooting, slow-motion video, and easier, better low-light shooting. It’s the most ‘invisible’ of the phones, as it just gets out of your way, so you can enjoy what you’re doing. If you like shooting on smartphones, I’d recommend that you give it a try.

If getting the best technical quality and detail is important to you, none of the improvements in the iPhone 5S is likely to appeal. Picture quality in good light hasn’t improved compared to the iPhone 5 - arguably it’s deteriorated a little. Picture quality in poor light has improved considerably, but is still far short of both the quality and usability of a dedicated camera for night photography.

The Feynman Lectures on Physics

Caltech has made the excellent Feynman Lectures on Physics available online (via Evan Hensleigh). The formatting looks great, with HTML5, SVG figures, and LaTeX equations rendered using MathJax.