I’ve known caffeinate for a long time, but I found a new use today that prompted me to write about it.
For those you don’t know, caffeinate is a command line tool that prevents your Mac from going to sleep. From it’s man page:
caffeinate creates assertions to alter system sleep behavior. If no
assertion flags are specified, caffeinate creates an assertion to prevent
idle sleep. If a utility is specified, caffeinate creates the assertions
on the utility’s behalf, and those assertions will persist for the duration of the utility’s execution.
Otherwise, caffeinate creates the assertions directly,
and those assertions will persist until caffeinate exits.
Let’s say you need to run a long task, like restoring a DB in postgres with pg_restore. The way you use caffeinate would be to run:
$ caffeinate -i pg_restore database database.dump
But let’s say you forgot to run caffeinate and your process has already been running for too long to cancel and restart. Before today, my approach was to use Caffeine to prevent the Mac from going to sleep. However, there’s a second way to invoke caffeinate:
$ caffeinate -i -w 12345
where 12345 is the pid of the process you want to finish without the Mac going to sleep.
I just updated an old post with a sample code on how to use UITableViewRowAction. The biggest new? I used an interactive Playground instead of the old sample code. When possible, I think it’s a much better way to share small projects for readers to try.
“At launch we’ll have iTunes, Netflix, Hulu, Showtime, and HBO — so we’ll have five major inputs into universal search
initially,” Cook said. “But we’re also opening an API, so that others can join in.”
I still have some questions:
How open will this API be? Any app can join? How do you prevent YouTube from populating your search results? What about Plex, or other apps that can play content not guaranteed to have been obtained legally?
From the demo we got, it seems that if you search for a movie or TV Show, you get a single screen with its metadata and sources to play from. How will Apple make movies and TV Shows unique on this search? Will they provide some sort of tool to look up the unique identifier of a given movie or show?
Ever since I got a Magic Mouse, I’ve been using MagicPrefs to configure a middle click on it (basically, to open Safari tabs in the background).
With El Capitan, Apple added a feature to shake the mouse to find the pointer. Even though I don’t need it too much, I was bummed to discover that this feature failes with MagicPrefs, so it gave me a good excuse to try BetterTouchTool instead, which works with this feature.
Overall, I like MagicPrefs better (it’s a System Preferences pane instead of only an app, and the settings are less cluttered), but I’ll be sticking to BetterTouchTool for now.
Here’s what I’ve been thinking about the next Apple TV.
Operating System and App Store
I think the Apple TV will run (as it has since the black hardware we currently have) a version of iOS. I’m guessing we’ll get a formal name for it: tvOS1.
tvOS will be the same familiar set of frameworks for iOS with some new top level UI elements (think the equivalent of UIKit) and support for a different interaction model (remote control clicks and selections instead of tapping, or swiping on a pad).
There’s no doubt in my mind that tvOS will support an App Store. I’m looking forward to apps like Plex to be natively available, as well as apps for TV channels and sports. The current channels on the Apple TV are limited in both functionality and features, while having a full blown App Store will allow developers to create better experiences for the TV.
If my guess is correct, all the existing apps will be easy to port, so we’ll have a large number of apps in weeks.
The Multiuser challenge
Let’s think of some scenarios:
If you have a tvOS running Apple TV with an App Store, it will make sense to have it support Handoff. Say you start watching a YouTube video on your iPhone, as soon as you enter your living room and turn the TV on, you can hand it off to the YouTube app running there, and you can leave your phone.
Say you use Spotlight on tvOS to search for a TV show. It will display results from the Netflix app, but Netflix supports different user profiles, some even filtering kids only content.
The main challenge I see here is that while iPhones are strictly personal devices, the Apple TV is a shared resource in a shared space at home. I don’t have an answer to this, but I’d love for tvOS to ship with an implementation of multi-user support. All iOS apps are already multi-user ready (whenever you get a folder from the OS, you use the same API as OS X that returns the current users folder), so this is doable.2
iOS is an amazing platform for gaming. Not only for indie games, but for AAA games as well. With a powerful hardware and Game Controller support the possibilities are huge.
I think the Apple TV has the potential of becoming a huge Game Console for casual (or why not all) gamers.
Given the time they got on stage, my guess is that Apple think of them as a big deal. HealthKit got its device with the Apple Watch. I think HomeKit is about to get its with the Apple TV.
As our homes become full of connected devices, having a central hub that is part of our home LAN and can be always on will be essential for controlling the devices while away.
I won’t speculate on the hardware, but from what 9to5mac published it appears that will get a fairly modern A-series CPU and a new remote.
I do have a few comments, though:
The CPU and GPU don’t need to be as speed-limited as in mobile devices. Even without a fan, I’m confident they can run it at higher clock speeds, or don’t have them throttle that fast.
Having IR on the remote doesn’t make much sense to me, unless Apple wants to make its remote a universal remote, which I don’t think. Universal Remotes are a mess3, and how well they work depends on the other components manufacturers4, which is something Apple doesn’t like.
The buildup for this Apple TV revision has been large. We can easily see traces of it in frameworks that originally shipped with iOS 8. I’m eager to see both new hardware and how Apple solves the challenges in the OS side.
And if we don’t get it, at least I’ll get to use it for the rest of this post. ↩
And if we get this feature, Apple will be running out of reasonable excuses to not include multi-user support on the iPad. ↩
Today we released CocoaPods thumbs. It’s a CocoaPods plugin that allows users to check for peer votes of the dependencies
they are including in the project. We are using it at Quadion (our thumbs are public, you can check them here).
We started using CocoaPods as soon as we discovered. It’s great for seasoned developers, but can quickly turn into a double-edged sword. Searching for the magical Podspec that solves a specific problem quickly becomes second nature to any developer (only second to copying and pasting unknown code from Stack Overflow).
The problem is that there are tons of Podspecs, and the quality varies hugely. From long time abandoned code, to code that violates AppStore submission rules by using private APIs, to code with too many bugs.
So I wanted to improve on this, at least a little bit, and then CocoaPods thumbs was born.
How it works
The use case is straigforward. There’s a server that returns a JSON with a given format, including Podspecs (with version requirements) and votes (optionally with comments).
Users first register the server URL (which conveniently can be a GitHub URL to the RAW JSON file), and then simply run pod thumbs from a folder with a Podfile. When run, CocoaPods thumbs will:
Calculate the dependencies.
Check the server votes.
Match the resolved dependencies with the votes, and display it to the users.
There’s also an alternative command to just display the votes of a single Podspec, useful to help you decide if a particular dependency has opinions among your team members.
I’m not sure how this will evolve. I’d love for this to become a part of CocoaPods daily usage for more people, and maybe consolidate our thumb lists instead of each team having their own. For now, if you use it, feel free to submig Pull Requests, or suggest enhancements on GitHub.
Installing Jenkins is usually easy. It’s even easier on the Mac using Homebrew. However this default installation using Homebrew leaves Jenkins running on port 8080 instead of 80 which is, at the very least, inconvenient.
Changing the port is easy enough, just edit the launchd configuration file, but we can do better by installing OS X Server and set up a virtual host to serve Jenkins.
Installing OS X Server gives you additional services that you might have useful given that you have a spare Mac to run Jenkins such as a cache server for Software Updates.
Installing OS X Server
OS X Server is available on the Mac App Store. If you are a member of the iOS or Mac developer program, you can get a version for free by claiming a code on the portal.
Installing Jenkins on OS X
There are several ways to install Jenkins. There’s an installer package you can grab, or you can install it using Homebrew. I choose Homebrew.
From a Terminal window type brew install jenkins.
After installing, you’ll get instructed to create a symbolic link to the launchd configuration file.
Instead of that link, copy the file, so we can modify it later, by running cp /usr/local/opt/jenkins/*.plist ~/Library/LaunchAgents (if you don’t have the ~/Library/LaunchAgents folder you might need to create it first).
Creating a Virtual Server on OS X Server’s Apache
On the Mac running OS X Server open the Server app. It will ask you to choose a server and then login.
Once in, choose Websites on the left menu. On the top-right you have a button to start Apache. On the bottom, there’s a list of Websites. Use the plus button to add a new one for Jenkins.
When editing the Virtual Host, choose a Domain Name such as jenkins.example.com.
If you go to Edit Advanced Settings… you’ll see the following screen:
except that you won’t have the webapp called “Jenkins using ajp13”. Let’s go ahead and create it.
Creating the Jenkins Webapp
Sidenote: OS X Server and Apache configuration files
While you can edit the Apache configuration file for the Jenkins Virtual Host you just created, OS X Server will overwrite it as soon as you make any changes to the Virtual Host using the UI. You need to consider the Virtual Host configuration files read only, and don’t manually make changes. Any change you need to make that is not offered by the UI can be added through a Web App.
Creating the Webapp
Webapps are defined with plist files stored in /Library/Server/Web/Config/apache2/webapps/. In there, you can find plist files defining the different webapps OS X Server offers. There’s a sample one called com.example.mywebapp.plist and you can get the documentation for this by running man webapp.plist.
The plist we1 created for Jenkins looks like this:
You can name this plist whatever you want. The naming convention is reverse URLs. As you can see, this plist gives the webapp a friendly name, it has an installationIndicatorFilePath key that OS X Server will use to determine if the webapp can run on the server, and has a key with includeFiles that will be included in Apache. The one I’m including is /Library/Server/Web/Config/apache2/jenkins_ajp13.conf and its contents are as follows:
What we do here is configure Apache to use mod_proxy_ajp to send some requests to Jenkins running the AJP13 protocol on port 8102.
Adding this webapp to your Virtual Host
In order to add this webapp to my Virtual Host, I had to restart the whole Mac running OS X server, as it didn’t show up on the Webapps panel. Your mileage may vary. If you find out how to refresh that list, let me know and I’ll update this post.
Configuring Jenkins to use AJP13
Remember I told you to copy the launchd configuration file instead of symlinking it? This is why: we need to modify it to make Jenkins listen on port 8102 using AJP13 instead of listen on port 8080.
Here’s how my modified homebrew.mxcl.jenkins.plist file looks:
You can now start Jenkins by running launchctl load ~/Library/LaunchAgents/homebrew.mxcl.jenkins.plist
And that’s it! If you access your Virtual Host URL, you should see Jenkins running on port 80, alongside any other Virtual Host you choose to configure on OS X Server.