<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Fickle Bits]]></title>
  <link href="http://benscheirman.com/atom.xml" rel="self"/>
  <link href="http://benscheirman.com/"/>
  <updated>2013-08-23T16:26:53+00:00</updated>
  <id>http://benscheirman.com/</id>
  <author>
    <name><![CDATA[Ben Scheirman]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[75 Essential Tools for iOS Developers]]></title>
    <link href="http://benscheirman.com/2013/08/the-ios-developers-toolbelt"/>
    <updated>2013-08-15T13:56:00+00:00</updated>
    <id>http://benscheirman.com/2013/08/the-ios-developers-toolbelt</id>
    <content type="html"><![CDATA[<p>If you were to go to a master woodworker&#8217;s shop, you&#8217;d invariably find a plethora of tools that he or she uses to accomplish various tasks.</p>

<p>In software it is the same. You can measure a software developer by how they use their tools.  Experienced software developers <em>master</em> their tools. It is important to learn your current tools deeply, and be aware of alternatives to fill in gaps where your current ones fall short.</p>

<p>With that in mind, I present to you a <em>gigantic</em> list of tools.  Some of these I use daily, others I see potential in.  If you have more tools you&#8217;d like to see here, just make sure to add a comment.</p>

<!--more-->


<p>I tried to categorize these the best I can.  Some of the entries are websites, some are back-end services, but most are apps that you install.  Not all of the apps are free, so I&#8217;ll make a note with a <em>$</em> to denote that an app costs money.</p>

<p>And without further ado, we&#8217;ll start from the beginning of any project, and that</p>

<h2>Inspiration</h2>

<ul>
<li><a href="http://pttrns.com">pttrns</a> - A great library of iOS screen designs categories
by task. If you want to see how other apps handle activity feeds, for instance,
this is a great place to go see a bunch of examples.</li>
<li><a href="http://tappgala.com">TappGala</a> - Another great collection of nice app designs.  It&#8217;s
not categorized by task, but is just a list of great apps to get inspiration from.</li>
<li><a href="http://cocoacontrols.com">Cocoa Controls</a> - A great list of components (code) that you
can use in your iOS apps.  Sometimes you&#8217;ll find great pieces of code that
can save you time, other times you can just learn how other developers accomplish certain
features.  Subscribe to their weekly newsletter; all signal, little noise.</li>
<li><a href="http://www.iicns.com">IICNS</a> - A collection of really great icons.  Get inspired, but don&#8217;t
copy.</li>
<li><a href="http://www.dribbble.com/search?q=ios">Dribbble</a> - Some of the best digital designers post up
their work for all to see. A treasure-trove of designs to look at.</li>
<li><a href="http://capptivate.co/">Capptivate</a> - a gallery of inspirational designs.  Some contain animations.  <em>Thanks, <a href="http://twitter.com/joaopmaia">@joaopmaia</a></em>!</li>
</ul>


<h2>Design</h2>

<ul>
<li><a href="http://celestialteapot.com/mocks">Mocks</a> ($) - An easy to use tool to create a quick
mockup of an iOS app.  Comes with a bunch of the default controls you can use to assemble
something quickly.</li>
<li><a href="http://giveabrief.com">Briefs</a> ($) - A really useful app that allows you to create a mockup of an app and stitch them together so you can see the interaction.  Deploy to a device so you can see what it feels like in your hand.</li>
<li><a href="http://www.flyingmeat.com/acorn/">Acorn</a> ($) - A strong competitor to Photoshop, only way cheaper.  I find myself reaching for Photoshop less &amp; less these days.  Under active development.</li>
<li><a href="http://www.bohemiancoding.com/sketch/">Sketch</a> ($) - A vector-based drawing tool that is increasingly useful these days, as screen sizes and pixel densities change.  It is often helpful to design once and have the freedom to scale up &amp; down as needed.  Also sports a really powerful export system.  For some example Sketch projects, check out <a href="http://sketchmine.co">Sketchmine</a>.  See my <a href="http://nsscreencast.com/episodes/079-sketch">screencast on Sketch</a> for a live demo.</li>
<li><a href="http://www.teehanlax.com/tools/ios7/">iOS 7 PSD by Teehan+Lax</a> - A super handy resource if you (or your designer) uses Photoshop.  An <a href="http://www.teehanlax.com/blog/ios-6-gui-psd-iphone-5/">iOS 6 version</a> is also available.</li>
<li><a href="http://bjango.com/articles/actions/">Bjango&#8217;s Photoshop Actions</a> - A definite time-saver if you use Photoshop to design iOS apps.  One click access to resize canvases, scale by 200% (or 50%), set global lighting to 90º, and more.  Their <a href="http://bjango.com/articles/">blog</a> also has a bunch of useful Photoshop workflow tips.</li>
<li><a href="http://xscopeapp.com/">xScope</a> ($) - An indespensible swiss-army knife of tools such as guides, pixel loupes, screen rulers, and more.  Want to know what color value that pixel is?  Want to see how many pixels between a button and the window for a random Mac app?  xScope has you covered.  Also check out their <a href="https://itunes.apple.com/app/xscope-mirror/id488819289?mt=8&amp;ign-mpt=uo%3D4">companion iPhone app</a> for <a href="http://xscopeapp.com/guide#mirror">mirroring designs</a> you&#8217;re working on and seeing them in pixel-perfect glory on your iDevice.</li>
<li><a href="http://glyphish.com">Glyphish</a> ($) - A fantastic collection of high quality icons for your iOS apps. Apple doesn&#8217;t provide a lot of built-in icons, so it&#8217;s handy to have a collection of icons covering all kinds of various concepts.  <em>I&#8217;m still looking for a use for that baby icon though</em>.  Glyphish comes in packs, and the latest pack has iOS 7 &#8220;thin line&#8221; icons which will be very handy when designing an iOS 7 app.</li>
<li><a href="https://github.com/AlexDenisov/FontasticIcons">Fontastic Icons for iOS</a> - An open source set of classes for utilizing icon fonts, such as <a href="http://fortawesome.github.io/Font-Awesome/">Font Awesome</a> in your iOS app.  Quickly and easily have an icon in whatever pixel dimensions you require.  Since fonts by nature can be scaled up and down with ease, this makes a really nice way to ship &amp; use your icons without having to export multiple versions for the sizes you require.</li>
<li><a href="http://paintcodeapp.com">PaintCode</a> ($) - A vector-based drawing tool that exports your artwork as the equivalent Core Graphics source code.  Awesome for learning how Core Graphics drawing works, but also incredibly handy if you want your drawing to be dynamic.  See my <a href="http://nsscreencast.com/episodes/80-paintcode">screencast on PaintCode</a> for a live demo.</li>
<li><a href="https://itunes.apple.com/us/app/edge-insets/id622650418?mt=12">Edge Insets</a> ($) - A simple tool that helps you define your edge insets for repeatable images.  Available on the Mac App Store.</li>
<li><a href="http://www.zambetti.com/projects/liveview/">LiveView</a> - A remote screen viewer for iOS, making it easy to immediately see your designs on a device.  <em>Thanks, <a href="http://twitter.com/_funkyboy">@_funkyboy</a></em>!</li>
<li><a href="http://bjango.com/mac/skalapreview/">Skala Preview</a> ($) - Another excellent tool for quickly showing your designs off on a real device.  The guys at Bjango are awesome and this app is deserving of the price.  <em>Thanks, jn40</em>!</li>
</ul>


<h2>Source Control</h2>

<ul>
<li><a href="http://gitscm.org/">Git</a> - If you&#8217;re not using source control stop what you&#8217;re doing and rectify that.  I use git for everything I do and love it.</li>
<li><a href="http://www.kaleidoscopeapp.com/">Kaleidoscope</a> ($) - The best diff/merge tool around.  Does 3-way merges and is beautiful to look at.  I use it every day.</li>
<li><a href="http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools">p4merge</a> - A free, ugly alternative to Kaleidoscope.  Powerful 3-way merge, but good luck finding the download link. It&#8217;s hidden deeper in their site every time I look for it.</li>
<li><a href="http://gitx.frim.nl/">Git X</a> - A simple, powerful GUI tool for visualizing git timelines and quickly &amp; easily staging commits.  I usually live in the Terminal for git usage, but fall back to this app when I need to stage hunks of changes into logical commits.  This is a fork of the original (abandoned) GitX, which I found on this <a href="http://gitx.org">list of forks</a>.</li>
<li><a href="http://www.sourcetreeapp.com/">Source Tree</a> - A free, full-featured Git application.  I don&#8217;t use this because I favor the command line, but if a GUI tool is your cup-o-tea, check this app out.</li>
</ul>


<h2>Dissecting Apps</h2>

<ul>
<li><a href="http://pmt.sourceforge.net/pngcrush/">pngcrush</a> - This little utility can <em>crush</em> &amp; <em>uncrush</em> PNG files, which is handy when you want to view images contained in app bundled distributed in the App Store.  Just open iTunes, view the local Apps list, and right click on any icon to Show in Finder.  Once there, open up the app and you&#8217;ll see a bunch of PNG files, but you can&#8217;t view them.  Using pngcrush you can extract the full version so it can be opened with Preview.</li>
<li><a href="https://github.com/boctor/idev-recipes/tree/master/Utilities/appcrush">appcrush.rb</a> - This handy little ruby script will automate the above process for all images.  Just point it to a <code>.app</code> file on your disk and it will extract all the images to a folder on your desktop.  Handy for seeing how apps on your phone accomplish certain designs.  Check out <a href="http://nsscreencast.com/episodes/20-dissecting-apps">my screencast on dissecting apps</a> for a live demo.</li>
<li><a href="http://charlesproxy.com">Charles</a> ($, free limited demo) - I don&#8217;t know what&#8217;s going on with the ugly UI or icon, but Charles is an <em>essential</em> tool for any developer.  Charles acts as a proxy to allow you to inspect your network traffic to &amp; from the iPhone Simulator.  You can also inspect traffic from your device by setting your phone&#8217;s proxy to your Mac running Charles.  With self-signed SSL certificates, request &amp; response breakpoints, and request/response viewers, Charles is really amazingly powerful.  A must-have tool.  Again, my screencast on <a href="http://nsscreencast.com/episodes/20-dissecting-apps">dissecting apps</a> covers this well.</li>
</ul>


<h2>Editors</h2>

<p>I know what you&#8217;re thinking, don&#8217;t all iOS developers use Xcode?  Well mostly, yes.  But with my love/hate relationship with Xcode, I believe there is tremendous value in considering alternatives.</p>

<ul>
<li><a href="http://jetbrains.com/objc">AppCode</a> - A full-fledged IDE from Jetbrains (makers of the excellent ReSharper for .NET).  Immensely powerful refactorings &amp; features that help you write code faster.  Quickly identify dead code, automatically insert <code>#import</code> statements when you use related code, easily extract variables, methods, and classes.  My only wish for this app is that it would instead be a plugin to Xcode.</li>
<li><a href="http://www.vim.org/">Vim</a> - Wait, vim?  Really?  Yes, there are folks who do all their Objective-C development in vim.  I&#8217;m not one of these, but I am a fan of vim for Ruby development.  As such, I&#8217;m a huge fan of&#8230;</li>
<li><a href="https://github.com/JugglerShu/XVim">Xvim</a> - An Xcode plug-in that gives you vim keybindings.  Works well, &#8216;nuff said.</li>
<li><a href="https://github.com/omz/ColorSense-for-Xcode">OMColorSense</a> - Another plugin for Xcode, this one gives you a small display of color when your cursor is on a line looking like: <code>[UIColor redColor]</code>.  Clicking on this little color tab opens a color picker that you can change, and any change in color you make is reflected in the code by changing the line to <code>[UIColor colorWithRed:… green:… blue:… alpha:… ]</code>.  When someone is watching me write code with this enabled, they invariably ask me, <em>&#8220;Whoa!  What was that?!&#8221;</em></li>
<li><a href="https://github.com/ksuther/KSImageNamed-Xcode">KSImageNamed</a> - Another Xcode plug-in, this one allows you to autocompleted image filenames from your bundle when typing <code>[UIImage imageNamed:…]</code>.  Great way to avoid the inevitable typo that causes this method to return <code>nil</code> and you to subsequently waste 10 minutes trying to figure out why your images aren&#8217;t displaying.</li>
<li><a href="https://github.com/kattrali/cocoapods-xcode-plugin">CocoaPods Xcode Plugin</a> - This plug-in adds a menu item for interacting with CocoaPods.  Useful if you don&#8217;t like dropping to the command line.</li>
<li><a href="http://mneorr.github.io/Alcatraz/">Alcatraz Package Manager</a> - An awesome meta plug-in that allows you to easily install other Xcode color schemes and plug-ins with a single click.</li>
<li><a href="https://itunes.apple.com/us/app/coderunner/id433335799?mt=12">Code Runner</a> ($) - a light-weight code-aware text editor that knows how to compile &amp; run code in most languages.  Want to test out a quick snippet of Objective-C code and don&#8217;t want to create an entire Xcode project to do it?  Code Runner to the rescue.</li>
</ul>


<h2>Documentation</h2>

<p>Ahhh, documentation, everyone&#8217;s favorite topic.  Even still, documentation is really important to have, so pay attention so we can make your life easier.</p>

<ul>
<li><a href="http://gentlebytes.com/appledoc/">appledoc</a> - Want to automatically generate documentation that look&#8217;s like Apple&#8217;s?  Look no further.  Automatically inter-links symbols defined in your project as well as extracting discussion to output using specially formatted code-comments.  Generates official docsets and HTML web sites.</li>
<li><a href="http://kapeli.com/dash/">Dash</a> ($) - A must-have API documentation viewer and code snippet manager.  This tool is really handy as it allows you to download &amp; search API docs for all kinds of languages &amp; frameworks with lightning speed.  The fastest way to get access to the docs.  I <a href="http://joeworkman.net/blog/post-30037947509">integrate Dash with Alfred</a> to make searches even faster.</li>
</ul>


<h2>Dependency Management</h2>

<p>Yes, there&#8217;s only one tool listed here.  I didn&#8217;t want to include actual 3rd party libraries, as that would be a different list entirely.  When it comes to dependency management, there&#8217;s only one game in town:</p>

<ul>
<li><a href="http://cocoapods.org/">CocoaPods</a> - The essential tool for Objective-C projects.  Allows you to quickly &amp; easily integrate 3rd party libraries into your application.  It does so by creating a second static library project and automatically links this with your projects.  There are thousands of pods available, and it&#8217;s easy to add support for libraries that you don&#8217;t own (or perhaps are private).  I use CocoaPods in every single project I work on.</li>
</ul>


<h2>Diagnostics &amp; Debugging</h2>

<p>At some point our app is in the field and we need to understand better what&#8217;s going on, maybe to fix bugs or to improve performance.</p>

<ul>
<li><a href="https://github.com/robbiehanson/CocoaLumberjack">Cocoa Lumberjack</a> - a much more powerful <code>NSLog</code>, Cocoa Lumberjack offers advanced logging behaviors such as logging to rotated files, logging to the network, and filtering based on log level (info, debug, warn, error).  Covered by <a href="http://nsscreencast.com/episodes/61-cocoa-lumberjack">NSScreencast Episode 61</a></li>
<li><a href="https://github.com/domesticcatsoftware/DCIntrospect">DCIntrospect</a> - crazy powerful tool that you&#8217;d link inside your app when running in debug and on the simulator.  Once you do, you can press the spacebar to get some really helpful view debugging support.  See exact dimensions of elements on the screen, print out view hierarchies, even nudge views horizontally or vertically.</li>
<li><a href="https://github.com/square/PonyDebugger">Pony Debugger</a> - another tool you&#8217;d use by embedding a library in your debug builds, Pony Debugger actually utilizes Chrome&#8217;s dev tools for seeing network requests coming out of the device, as well as a rudimentary Core Data browser.  It&#8217;s hard to describe, but check out my <a href="http://nsscreencast.com/episodes/54-pony-debugger">screencast on Pony Debugger</a> for more info.</li>
<li><a href="http://runscope.com/">Runscope</a> ($) - Runscope is a service running online that can capture requests, log details, and give you valuable data about your API.  Simple to set up, as it&#8217;s an HTTP pass-through API, all you need to change is your host name.</li>
<li><a href="http://simpholders.com/">SimPholders</a> - Quick, easy access to your simulator folders.  Browse by iOS version, then app name and jump right to the folder in Finder.</li>
<li><a href="http://sparkinspector.com/">Spark Inspector</a> - Debug your view hierarchy running on your app in debug mode, in 3D.  This app really has to be seen to fully understand the value, but it can really help to understand what views are used to compose your app.  Also contains a notification center inspector, so you can easily see what <code>NSNotification</code>s are firing and who is observing them.  Another app to look at that is similar is <a href="http://revealapp.com">Reveal</a>.</li>
</ul>


<h2>Images</h2>

<ul>
<li><a href="http://pngmini.com/">ImageAlpha</a> - A Mac app that allows you to convert a 24-bit PNG with transparency to an 8-bit PNG with an alpha channel.  Typically 8-bit PNGs don&#8217;t have an alpha channel, so if your image can be represented in 8-bits (say, a solid color button) you can save a lot on storage by converting the 24-bit PNG to 8-bit using ImageAlpha.</li>
<li><a href="http://imageoptim.com/">ImageOptim</a> - Another Mac app that compresses PNGs in order to save space.  Most PNG files can shave off a few % of the size, and sometimes you&#8217;ll shrink the files by 30% or more.  Smaller images mean smaller app sizes and less memory used to load them at runtime.</li>
<li><a href="http://wearemothership.com/work/prepo">Prepo</a> - A little Mac app that can quickly resize artwork in all the various sizes you might need.  Just drag a large icon file (say, 1024x1024) onto Prepo and watch it spit out 512x512 iTunesArtwork, 114x114 Icon@2x.png, and all the other sizes &amp; filenames you&#8217;d expect.</li>
<li><a href="http://dragonforged.com/slender/">Slender</a> ($) - an awesome app that analyzes your app and finds all sorts of problems, such as missing retina artwork, unused images, image that could benefit from compression and more.  Shave kilobytes off of your iPhone app by shedding unused images with Slender.</li>
</ul>


<h2>Core Data</h2>

<ul>
<li><a href="http://rentzsch.github.com/mogenerator/">Mogenerator</a> - still a super useful tool for generating smart subclasses of your <code>NSManagedObject</code>s in your Core Data model.  Some use Xcode for this, and resort to manually subclassing or creating categories in order to add logic to the models.  Mogenerator runs as a quick pre-compile script to generate subclasses for you to use.  It does this by creating an underscored version (<code>_User</code>) and a regular one for you to modify (<code>User</code>).</li>
<li><a href="http://menial.co.uk/software/base/">Base</a> ($) - there will come a time when you need to inspect your actual Core Data sqlite database to see what&#8217;s going on.  You can use the <code>sqlite3</code> command line tool, but Base offers a nice looking GUI browser.  Just don&#8217;t vomit when you see the database schema that Core Data created for you.</li>
<li><a href="http://christian-kienle.de/CoreDataEditor">Core Data Editor</a> ($) - for more advanced data anlysis, exploration, and modification you can use Core Data Editor.  This app understands Core Data, so you&#8217;re working directly with the entities instead of database rows.</li>
</ul>


<h2>Back-end Services</h2>

<p>Ultimately your iOS app will likely want to talk to a server to share data, fetch new content, send push notifications or whatever.  While this can be accomplished manually, you might want a more drop-in solution.</p>

<ul>
<li><a href="http://helios.io">Helios</a> - Helios is an open-source framework that provides essential backend services for iOS apps, from data synchronization and push notifications to in-app purchases and passbook integration.  Built on top of many open source ruby gems, so you can pick &amp; choose and build your own stack if you so desire.  Take a look at the <a href="http://nomad-cli.com/">Nomad CLI</a> set of handy related tools as well.</li>
<li><a href="http://www.windowsazure.com/en-us/develop/mobile/">Windows Azure Mobile Services</a> - you can think of this sort of like a programmable database in the cloud.  Create tables, run JavaScript on read, insert, delete to add additional functionality.  Really easy support for push notifications as well.</li>
<li><a href="http://urbanairship.com">Urban Airship</a> - I&#8217;ve been using Urban Airship to deliver push notifications for a while now.  Really easy to integrate with, and small usage is free.</li>
<li><a href="http://parse.com">Parse</a> - This is another data-in-the-cloud service, but offers an impressive API and online data browser.  We use Parse for a really small app and works well for that.</li>
</ul>


<h2>Analytics</h2>

<p>There are other players here, but none that I&#8217;ve seen have been compelling enough to switch from flurry.  I&#8217;m open to hearing suggestions, so let&#8217;s hear about &#8216;em in the comments.</p>

<ul>
<li><a href="http://flurry.com">Flurry</a> - I&#8217;ve used flurry for a long time to provide useful analytics on the usage of my apps.  Need to know when to stop supporting iOS 5?  Flurry gives you the numbers to have a realistic conversation.</li>
</ul>


<h2>Deployment</h2>

<ul>
<li><a href="http://www.deploymateapp.com/">Deploymate</a> ($) - Need to support iOS 4 still, but you&#8217;re compiling with the iOS 6 SDK?  Deploymate will warn you when you&#8217;re using symbols that don&#8217;t exist in your deployment target.</li>
<li><a href="https://github.com/nomad/cupertino">Cupertino</a> - Part of the Nomad CLI tools, Cupertino gives you command line access to managing devices &amp; profiles in the Apple Provisioning Portal.  For example, just type <code>ios devices:list</code> to see the current list of devices in your account.  Useful for automating lots of processes.</li>
<li><a href="http://hockeyapp.net/">Hockey App</a> ($) - A great service for managing the distribution of your ad-hoc builds.  Testers can get a link to install new betas over the air.  Also provides robust crash reporting so you can easily respond to crashes in your apps.</li>
<li><a href="http://testflightapp.com">TestFlight</a> - A free service, similar to Hockey App.  We&#8217;ve used TestFlight with great success for easily distributing apps and collecting feedback from our users.  My only wish is that they&#8217;d start charging for the service.  Also includes analytics and crash reporting, but we don&#8217;t use those features.</li>
<li><a href="http://www.curioustimes.de/iphonesimulatorcropper/index.html">iOS Simulator Cropper</a> - A really easy way to snap images of the simulator, with or without status bar, with or without device chrome, etc.  Great for taking App Store or just general marketing screenshots.</li>
<li><a href="http://shinydevelopment.com/status-magic/">Status Magic</a> ($) - Take better app store screenshots.  Nothing makes your app look less crappy than an App Store screenshot that includes a low battery, or low signal.  Status Magic gives you complete customization over what&#8217;s present in your status bar, including removing elements, changing the time to &#8220;9:41 AM&#8221; like Apple tends to do, and more.</li>
<li><a href="http://crashlytics.com">Crashlytics</a> - Excellent crash reporting for your apps in the field.  Automatically uploads dSYMs on release builds so your crashes are automatically symbolicated and organized for you to focus on the most critical ones.</li>
</ul>


<h2>Testing</h2>

<p>I don&#8217;t think we as a community focus enough on testing. There are great tools available to us, and most are so easy to use we have no real excuse not to write at least some tests for our apps.</p>

<ul>
<li><a href="https://github.com/allending/Kiwi">Kiwi</a> - A great Rspec-style testing framework for iOS.  Built on top of SenTestingKit, so you just type <code>⌘U</code> to run your specs.  Also includes a completely robust mocking &amp; stubbing library as well as assertions.</li>
<li><a href="https://github.com/specta/specta">Specta</a> - A light-weight BDD framework very similar to Kiwi, but the expectation syntax has one major benefit over Kiwi:  everything is implicitly boxed like this:  <code>expect(items.count).to.equal(5)</code>.  There&#8217;s no need to wrap <code>5</code> in an <code>NSNumber</code> like Kiwi does.  Use in conjunction with <a href="https://github.com/specta/expecta/">Expecta</a> for a bunch of useful matchers.</li>
</ul>


<p>The following are all various ways of performing end-to-end acceptance tests.  These tests will actually interact with your interface, touching buttons, scrolling, etc.  By nature these will be slower and more brittle, but testing in broad strokes is certainly helpful to see if all of the pieces fit together properly.</p>

<ul>
<li><a href="https://github.com/square/KIF">KIF</a></li>
<li><a href="https://github.com/calabash/calabash-ios">Calabash</a></li>
<li><a href="http://www.zucchiniframework.org/">Zucchini</a></li>
<li><a href="http://testingwithfrank.com/">Frank</a></li>
<li><a href="https://github.com/bendyworks/bwoken">Bwoken</a></li>
</ul>


<h2>Demos / Marketing</h2>

<ul>
<li><a href="http://www.airsquirrels.com/reflector/">Reflector</a> ($) - Wirelessly mirror your iOS device on your Mac using Air Play.  Great for doing demos of applications on your computer.</li>
<li><a href="http://placeit.breezi.com">Placeit</a> - A great collection of high res photos of people using devices, but the screens are templates that you can insert your own screenshots into.  Very cool, and great for displaying your app in a nice way on your website.</li>
</ul>


<h2>App Sales Reporting</h2>

<p>Of course you want to be able to see how much money you&#8217;re making on your app, right?  There are a few solutions for this, but here are a couple that work well:</p>

<ul>
<li><a href="http://www.ideaswarm.com/AppViz2.html">App Viz 2</a> ($) - a really useful Mac app for tracking sales of your apps.  You run it locally and it logs in and downloads your sales reports.</li>
<li><a href="http://www.appannie.com/">App Annie</a> - an online sales reporting tool.  I&#8217;m less comfortable giving my credentials to iTunes to a 3rd party, but it does keep the reports up to date for you so you don&#8217;t have to run an app locally.  <em>In the comments, Josh Brown suggests creating a different user for analytics in iTunes Connect, which is a really good idea.</em></li>
</ul>


<h2>Grab Bag</h2>

<p>These tools don&#8217;t have a defined category above, but deserve a mention nonetheless.</p>

<ul>
<li><a href="http://www.quickradar.com/">Quick Radar</a> - Submitting bug reports to Apple is our only way of making their tools better.  If you&#8217;re frustrated by the lack of a feature, <em>you should be submitting a bug report</em>.  If you come across a bug, <em>you should be submitting a bug report</em>.  One has no right to complain if they have not yet filed a radar :).  With that in mind, submitting bug reports via <a href="http://bugreporter.apple.com">bugreporter</a> feels like a trip back to 1995.  Quick Radar is an awesome little app that makes submitting bug reports super easy.  Sports automatic posting to open radar so others can see it, in addition to tweeting, and posting to App.net.  I use this app several times per week.</li>
</ul>


<p>And there you have it.  A gigantic <em>wall of tools</em>.  Hopefully you learned about a few new ones you can add to your arsenal.  If you enjoyed this post, please check out my iOS screencasts over at <a href="http://nsscreencast.com">NSScreencast</a>.</p>

<p><a href="http://nsscreencast.com"><img src="http://benscheirman.com/images/nsscreencast-footer.png" alt="NSScreencast - Weekly bite-sized videos on iOS development." /></a></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Speaking at Cocoa Conf PDX]]></title>
    <link href="http://benscheirman.com/2013/07/speaking-at-cocoa-conf-pdx/"/>
    <updated>2013-07-13T18:17:00+00:00</updated>
    <id>http://benscheirman.com/2013/07/speaking-at-cocoa-conf-pdx</id>
    <content type="html"><![CDATA[<p>I have the pleasure of speaking at <a href="http://cocoaconf.com/portland-2013">Cocoa Conf PDX</a> on August 15-16th.
Cocoa Conf is always a great event, and I especially love traveling to my home state of Oregon.  This time around I&#8217;ll be giving
two talks:</p>

<ul>
<li>The iOS Developer&#8217;s Toolbelt</li>
<li>Jenkins - Your personal butler for iOS automation</li>
</ul>


<p><a href="http://cocoaconf.com/portland-2013/home"><img src="http://cocoaconf.com/images/speaking/cc-pdx-2013.png" /></a></p>

<p>I hope to see you there!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[In Search of a Fast External Hard Drive]]></title>
    <link href="http://benscheirman.com/2013/02/in-search-of-a-fast-external-hard-drive/"/>
    <updated>2013-02-02T11:46:00+00:00</updated>
    <id>http://benscheirman.com/2013/02/in-search-of-a-fast-external-hard-drive</id>
    <content type="html"><![CDATA[<p>Ever since I upgraded to a retina MacBook Pro, I knew I&#8217;d have to come up with a new strategy for storing data. Even after upgrading to the 512GB SSD, I&#8217;m still running out of space.
With hundreds of gigabytes for pictures, music, videos, and games a 512GB SSD is perfectly reasonable.  But now that <a href="http://nsscreencast.com">NSScreencast</a>
 is nearing a year old I have more data than I can store on a single drive.  Another nuissance was transferring these videos over to my iMac for editing.<br/>
A typical 20 minute screencast of mine will eat up nearly 8 gigabytes before encoding, and transfering a file like this over Wi-Fi is painfully slow.</p>

<p>On my previous MacBook Pro I opted to remove the superdrive and install a 2nd 7200 RPM drive for larger storage.  This worked well, but the retina MacBook Pro has no such capability,
so I went on the lookout for an external drive to store NSScreencast videos.</p>

<!--more-->


<h2>Requirement #1: Speed</h2>

<p>The first requirement was that the drive had to be fast.  Ideally I&#8217;d record directly to the drive and then I&#8217;d be free to move it over to the iMac and just plug it in.</p>

<h2>Requirement #2: Connections</h2>

<p>My MacBook Pro has Thuderbolt, which, at 10 Gb/s, is very attractive.  However my late-2009 iMac does not have Thunderbolt, this severely limits my options.</p>

<p>My MBP has USB 3.0 ports, and most (if not all) USB 3.0 drives are backward compatible with USB 2.0.  For reference, USB 3.0 speed is 5Gb/s, and USB 2.0 is 480 Mb/s.</p>

<p>This means, provided we had a fast enough drive, a Thunderbolt connection could yield up to 1.25 Gigabytes per second data transfer.  This is crazy fast, and unfortunately there isn&#8217;t a drive on the planet (yet) that reads or writes this fast.</p>

<h2>Requirement #3: Size</h2>

<p>Most of the time when going for an external drive it is for backup reasons, so size is king.  But in my case I was willing to forego size for the right drive.</p>

<h2>The Drives</h2>

<p>Initially I was eyeing this <a href="http://www.amazon.com/BUFFALO-MiniStation-Thunderbolt-Portable-Drive/dp/B008D4X9UI/">Buffalo 1TB Thunderbolt USB 3.0/2.0 Drive</a> because it seemed like it would satisfy both connectivity and size requirements.  But on further inspection, they seem to have just placed a 5400 RPM drive in here.  A few reviewers posted their transfer speeds, and looks to be around 80 MB/s.  Considering that a 1TB external USB 3.0 drive is only around $100 these days, this drive (at $200), was clearly not a good choice.</p>

<p>I recently got a <a href="http://www.amazon.com/Passport-Portable-External-Drive-Storage/dp/B005HMKKH4/">USB 3.0 Western Digital 2TB My Passport</a> for time machine backups, which replaced an older 7200 RPM drive in a 3rd party USB enclosure.</p>

<p><img src="http://benscheirman.com/images/wdpassport2tb.png" alt="Western Digital My Passport 2TB USB 3.0 drive" /></p>

<p>The 7200 RPM drive was my baseline.  It&#8217;s been a handy external drive for a long time, but being USB 2.0, it was going to be the slowest possible choice.</p>

<p>I realized that to saturate USB 3.0 at 5Gb/s, I&#8217;d need a drive that can write that fast.  SSD&#8217;s are the clear choice here, and after a bit of research I picked up a <a href="http://eshop.macsales.com/item/OWC/SSDEX6G240/">240GB Mercury Electra 6Gbps SSD</a> from <a href="http://macsales.com">OWC</a>.  This drive boasts write speeds of up to 500 MB/s!</p>

<p><img src="http://benscheirman.com/images/owc-240gb-ssd.jpeg" alt="OWC Mercury Electra SSD - 240GB" /></p>

<p>  Along with the drive I purchased their <a href="http://eshop.macsales.com/shop/USB2/OWC_Express">USB 3.0 / 2.0 enclosure</a>.</p>

<p><img src="http://benscheirman.com/images/owc-enclosure.jpeg" alt="OWC USB 3.0 Enclosure" /></p>

<p>So the main question is, is it worth it to buy such an expensive drive for your external drive needs?  Time to run some benchmarks.</p>

<p><img src="http://benscheirman.com/images/drives-to-test.jpeg" alt="The drives" /></p>

<h2>The Tests</h2>

<p>I used the freely available <a href="http://www.aja.com/en/products/software/">AJA Disk Test</a> tool to perform a benchmark. I used the 1920x1080 10-bit video file test with a size of 16 GB.  The file is written to disk and then read back again.  All drives were empty when performing the test.</p>

<h3>Western Digital Raptor 320GB 7200 RPM drive via USB 2.0</h3>

<p>This was obviously the slowest of the bunch, but for comparison, this is my baseline.  The drive boasted a write speed of <strong>38 MB/s</strong> and a read speed of <strong>41 MB/s</strong>.</p>

<p><img src="http://benscheirman.com/images/raptor-aja-disk-test.png" alt="WD 7200 RPM drive results" /></p>

<h3>Western Digital 2TB My Passport (USB 3.0)</h3>

<p>This drive posted better results that the previous drive, but it doesn&#8217;t even come close to saturating the USB 3.0 pipe, which could potentially yield around 625 MB/s.  Doing the same test above, this drive benchmarked a write speed of <strong>94.2 MB/s</strong> and a read speed of <strong>92.9 MB/s</strong>.</p>

<p><img src="http://benscheirman.com/images//wdpassport-aja-disk-test.png" alt="WD 2TB My Passport USB 3.0 results" /></p>

<h3>OWC Mercury Electra 6G SSD - 240GB via USB 3.0</h3>

<p>This drive is slightly held back by being on a USB bus rather than direct SATA connection, but still posted impressive speeds.  The test resulted in a <strong>284.3 MB/s</strong> write speed and a <strong>250.7 MB/s</strong> read speed.</p>

<p><img src="http://benscheirman.com/images/owc-aja-disk-test.png" alt="OWC Mercury Electra SSD - USB 3.0" /></p>

<h2>Conclusion</h2>

<p>Here are the read &amp; write speeds for each drive side by side.  The result is clear.</p>

<p><img src="http://benscheirman.com/images/drive-test-graph.png" alt="Drive test results" /></p>

<p>The SSD version is more than twice as fast than any packaged USB 3.0 drive out there.  In addition, it doesn&#8217;t suffer from seek delay, some random access should be much quicker as well.  I did noticed that OWC sells their own external SSD (which I wish I had seen before purchasing mine) but I suspect it will receive similar speeds, and the combo I purchased is actually about $80 cheaper.</p>

<p>SSDs continue to kick major ass, so here&#8217;s to hoping they drop in price.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Serving Assets from S3 on Heroku]]></title>
    <link href="http://benscheirman.com/2012/07/serving-assets-from-s3-on-heroku/"/>
    <updated>2012-07-07T11:17:00+00:00</updated>
    <id>http://benscheirman.com/2012/07/serving-assets-from-s3-on-heroku</id>
    <content type="html"><![CDATA[<p>Recently I changed <a href="http://nsscreencast.com">NSScreencast</a> to use a <a href="http://en.wikipedia.org/wiki/Content_delivery_network">CDN</a>
to serve up assets from a different, faster server.</p>

<h2>Why use a CDN?</h2>

<p>Using a CDN has numerous benefits.  First, and foremost, this alleviates a bunch of secondary requests that
would normally hit your webserver.  Loading the home page of NSScreencast loads more than a dozen images, stylesheets, and
javascript files.  When deploying to Heroku this can be especially problematic as each asset request will occupy one of your
dynos for a short time.  In the spirit of maximizing your free dyno on Heroku, not sending these requests to your app is definitely
a big win.</p>

<p>In addition, most browsers have a setting that limits the number of connections (usually 2) that it will open
in parallel to a given domain.  By using a CDN, you can increase the number of parallel requests
because these assets are not served up by your application&#8217;s domain.</p>

<p>It&#8217;s also a common practice to use dns to &#8220;alter&#8221; the domain so that you can maximize this parallelization.</p>

<h2>Using the asset sync gem</h2>

<p>Following the instructions on <a href="https://devcenter.heroku.com/articles/cdn-asset-host-rails31">Heroku&#8217;s Devcenter article</a> I
decided to use the <code>asset_sync</code> gem.  This gem will upload your compiled assets to your preferred CDN (any file storage server that
<a href="https://github.com/fog/fog/">fog</a> supports).  In my case, I wanted to use S3.</p>

<p>The first step is adding this gem to your <code>Gemfile</code>:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">group</span> <span class="ss">:assets</span> <span class="k">do</span>
</span><span class='line'>  <span class="c1"># other asset gems</span>
</span><span class='line'>  <span class="n">gem</span> <span class="s1">&#39;asset_sync&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>It&#8217;s important to put this in your asset group, as your running app doesn&#8217;t need to load this into memory.</p>

<p>Then you need to configure the gem.  I found Heroku&#8217;s instructions to be lacking here, as I had to dig into
the <a href="https://github.com/rumblelabs/asset_sync"><code>asset_sync</code> github page</a> to make this work.</p>

<p>Add a file called <code>config/initializers/asset_sync.rb</code> to your app:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># Since this gem is only loaded with the assets group, we have to check to </span>
</span><span class='line'><span class="c1"># see if it&#39;s defined before configuring it.</span>
</span><span class='line'><span class="k">if</span> <span class="n">defined?</span><span class="p">(</span><span class="no">AssetSync</span><span class="p">)</span>
</span><span class='line'>  <span class="no">AssetSync</span><span class="o">.</span><span class="n">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
</span><span class='line'>    <span class="n">config</span><span class="o">.</span><span class="n">fog_provider</span> <span class="o">=</span> <span class="s1">&#39;AWS&#39;</span>
</span><span class='line'>    <span class="n">config</span><span class="o">.</span><span class="n">aws_access_key_id</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;AWS_ACCESS_KEY_ID&#39;</span><span class="o">]</span>
</span><span class='line'>    <span class="n">config</span><span class="o">.</span><span class="n">aws_secret_access_key</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;AWS_SECRET_ACCESS_KEY&#39;</span><span class="o">]</span>
</span><span class='line'>    <span class="n">config</span><span class="o">.</span><span class="n">fog_directory</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;FOG_DIRECTORY&#39;</span><span class="o">]</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1"># Fail silently.  Useful for environments such as Heroku</span>
</span><span class='line'>    <span class="n">config</span><span class="o">.</span><span class="n">fail_silently</span> <span class="o">=</span> <span class="kp">true</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>That last config line is important.  When you deploy to Heroku, your app&#8217;s assets will get precompiled.  But because Heroku
doesn&#8217;t initialize your app on precompile, none of your settings will be available.  Instead we&#8217;ll have to run the precompile again,
manually, to get AssetSync to kick in.</p>

<h2>Setting up the configuration with Heroku San</h2>

<p>Since I like to have multiple environments, I use <a href="https://github.com/fastestforward/heroku_san"><code>heroku_san</code></a> to manage them, including
the environment variables.</p>

<p>Inside of <code>config/heroku.yml</code>, set up the following for each environment:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">FOG_PROVIDER</span><span class="p">:</span> <span class="s2">&quot;AWS&quot;</span>
</span><span class='line'><span class="no">FOG_DIRECTORY</span><span class="p">:</span> <span class="s2">&quot;nsscreencast-assets&quot;</span>
</span><span class='line'><span class="no">AWS_ACCESS_KEY_ID</span><span class="p">:</span> <span class="s2">&quot;&lt;your access key&gt;&quot;</span>
</span><span class='line'><span class="no">AWS_SECRET_ACCESS_KEY</span><span class="p">:</span> <span class="s2">&quot;...&quot;</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Configuring Your Rails app to use S3 as an Asset Host</h2>

<p>In your <code>config/production.rb</code> (and <code>staging.rb</code> if you have one), make sure to add the
following line to allow Rails to generate the appropriate links for your assets:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'>  <span class="n">config</span><span class="o">.</span><span class="n">action_controller</span><span class="o">.</span><span class="n">asset_host</span> <span class="o">=</span> <span class="no">Proc</span><span class="o">.</span><span class="n">new</span> <span class="k">do</span> <span class="o">|</span><span class="n">source</span><span class="p">,</span> <span class="n">request</span><span class="o">|</span>
</span><span class='line'>    <span class="n">scheme</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="n">ssl?</span> <span class="p">?</span> <span class="s2">&quot;https&quot;</span> <span class="p">:</span> <span class="s2">&quot;http&quot;</span>
</span><span class='line'>    <span class="s2">&quot;</span><span class="si">#{</span><span class="n">scheme</span><span class="si">}</span><span class="s2">://</span><span class="si">#{</span><span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;FOG_DIRECTORY&#39;</span><span class="o">]</span><span class="si">}</span><span class="s2">.s3.amazonaws.com&quot;</span>
</span><span class='line'>  <span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This will allow your app to serve up the URLs using SSL if the request is coming via SSL.  Doing
this can avoid warnings in the browser that your app contains secure and unsecure content.</p>

<h2>Testing it all out</h2>

<p>If all of this is configured correctly, you can test it out by doing a push&#8230;</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">git</span> <span class="n">push</span> <span class="n">heroku</span> <span class="n">master</span>
</span></code></pre></td></tr></table></div></figure>


<p>You&#8217;ll see the asset precompile going on in the logs, and likely an error related to AssetSync.  This is fine (and
in fact, this tripped me up at first).  Once
the deploy has completed, you&#8217;ll have to run this command to upload your assets:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">heroku</span> <span class="n">run</span> <span class="n">rake</span> <span class="n">assets</span><span class="ss">:precompile</span> <span class="o">--</span><span class="n">app</span> <span class="o">&lt;</span><span class="n">yourapp</span><span class="o">&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Doing this, you should see something like the following output:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="no">Precompiling</span> <span class="n">assets</span><span class="o">.</span><span class="n">.</span><span class="o">.</span>
</span><span class='line'><span class="no">Uploading</span><span class="p">:</span> <span class="n">application</span><span class="o">.</span><span class="n">css</span>
</span><span class='line'><span class="no">Uploading</span><span class="p">:</span> <span class="n">application</span><span class="o">.</span><span class="n">css</span><span class="o">.</span><span class="n">gz</span>
</span><span class='line'><span class="no">Uploading</span><span class="p">:</span> <span class="n">image1</span><span class="o">.</span><span class="n">png</span>
</span><span class='line'><span class="no">Uploading</span><span class="p">:</span> <span class="n">image2</span><span class="o">.</span><span class="n">png</span>
</span><span class='line'><span class="o">.</span><span class="n">.</span><span class="o">.</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Set up Heroku San to do this on every deploy</h2>

<p>I&#8217;d likely forget to run this command every once in a while, so I set up Heroku San to run this command
after every deploy.</p>

<p>To do this, add a new rake task in your app (<code>lib/tasks/deploy.rake</code>):</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">task</span> <span class="ss">:after_deploy</span> <span class="k">do</span>
</span><span class='line'>  <span class="no">HerokuSan</span><span class="o">.</span><span class="n">project</span><span class="o">.</span><span class="n">each_app</span> <span class="k">do</span> <span class="o">|</span><span class="n">stage</span><span class="o">|</span>
</span><span class='line'>    <span class="nb">puts</span> <span class="s2">&quot;---&gt; Precompiling asssets &amp; uploading to the CDN&quot;</span>
</span><span class='line'>    <span class="nb">system</span><span class="p">(</span><span class="s2">&quot;heroku run rake assets:precompile --app </span><span class="si">#{</span><span class="n">stage</span><span class="o">.</span><span class="n">app</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Now when you run your deploy via <code>rake production deploy</code> this will happen automatically.</p>

<h2>So what&#8217;s the net result?</h2>

<p>Doing this alleviated nearly 30 secondary requests to my application for each page load.  That alone is pretty huge.  Also, S3 is
much faster at serving these assets than nginx is (at least via a Heroku app on 1 dyno).</p>

<p>I tested this before and after by clearing the cache and doing a fresh page load.  Using the Chrome Inspector, I looked at the time to load the page and all assets.
Here are my findings:</p>

<table style="margin: 25px;">
  <tr>
    <td style="border: solid 1px #ddd; padding: 3px 7px;">
      <strong>Before</strong> (<em>serving assets with no CDN</em>)
    </td>
    <td style="border: solid 1px #ddd; padding: 3px 7px;">3.27 seconds</td>
  </tr>
  <tr>
    <td style="border: solid 1px #ddd; padding: 3px 7px;"><strong>After</strong>
    (<em>using S3 as a CDN</em>)
    </td>
    <td style="border: solid 1px #ddd; padding: 3px 7px;">1.07 seconds</td>
  </tr>
</table>


<p>That&#8217;s a huge gain for a minor change in your application &amp; deployment process.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Hello, NSScreencast]]></title>
    <link href="http://benscheirman.com/2012/02/hello/"/>
    <updated>2012-02-10T06:27:00+00:00</updated>
    <id>http://benscheirman.com/2012/02/hello</id>
    <content type="html"><![CDATA[<p><a href="http://nsscreencast.com">NSScreencast</a> is now live. The first 2 videos have been posted:</p>

<ul>
<li><a href="http://nsscreencast.com/episodes/1-objective-c-basics">Objective-C Basics</a></li>
<li><a href="http://nsscreencast.com/episodes/2-diagnosing-memory-problems">Diagnosing Memory Problems</a></li>
</ul>


<p>Now that the site has launched, I can share more details with you about it.</p>

<h3>A new video each week</h3>

<p>Each week, a new video will be posted covering a single, focused topic related to iOS development.</p>

<h3>Don&#8217;t waste the listener&#8217;s time</h3>

<p>Each video will be short and to the point. It boils down to this: a 20 minute video is an easy thing to watch.  A 60-minute video is a serious time commitment.</p>

<h3>Some Free, Some Paid</h3>

<p>Eventually, NSScreencast will be a subscription service.  I&#8217;ll announce details once they are nailed down, but for now, enjoy the videos!
If you&#8217;d like to be notified when an episode is released, you can <a href="http://feeds.feedburner.com/NSScreencast">subscribe to the RSS feed</a>,
or follow <a href="http://twitter.com/nsscreencast">@nsscreencast</a> on twitter.  (<em>Subscribing in iTunes is coming soon</em>)</p>

<p>If you have any video topic suggestions, feel free to share them at the <a href="http://nsscreencast.uservoice.com">User Voice Forum</a>.
Seriously, I&#8217;d love to hear your feedback!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[NSScreencasts, Coming Soon]]></title>
    <link href="http://benscheirman.com/2012/01/nsscreencasts/"/>
    <updated>2012-01-19T22:47:00+00:00</updated>
    <id>http://benscheirman.com/2012/01/nsscreencasts</id>
    <content type="html"><![CDATA[<h2>Bite-Sized Learning</h2>

<p>Video training is becoming a very common way to learn these days.  With <a href="http://tekpub.com">Tekpub</a>, <a href="http://peepcode.com/">Peepcode</a>, <a href="http://pluralsight.com">Pluralsight</a>,
<a href="http://codeschool.com">Code School</a>, and many others, there are usually great productions to teach you any development topic that you&#8217;d want to learn about.</p>

<p>All of these services are great, however I&#8217;m becoming a fan of the smaller, more focused screencasts.  <a href="http://railscasts.com">Railscasts</a>, for instance, has
been <em>instrumental</em> to my Rails learning development.  <a href="http://destroyallsoftware.com/">Destroy all Software</a> teaches me new things every week.</p>

<p>Smaller videos like this are easier to digest, and are more focused on a single topic.  Like the <a href="http://en.wikipedia.org/wiki/Boiling_frog">boiled frog</a>
you eventually realize how far you&#8217;ve come on a topic, simply by watching regular videos.</p>

<p>iOS Development is an ever-changing landscape, with so many topic areas to cover, that a single training class or screencast series just
can&#8217;t teach you all of it.  Instead of trying to cover everything in depth (increasing the length of videos). I find it valuable to
have smaller, focused tutorials that teach you one thing, and do it quickly and effectively.</p>

<h2>Introducing NSScreencast</h2>

<p><a href="http://nsscreencast.com">NSScreencast</a> will be launching soon and will feature regular bite-sized videos
focused on a single topic related to Objective-C and building iOS applications.</p>

<p>NSScreencast <em>will</em> include free videos. Down the road, a nominal paid subsribtion will unlock access to more content.</p>

<p>I still have lots to do before I release the first video, but if you like the idea, please sign up on
the site to be notified when it launches. Thanks!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Careful With Block-Based Notification Handlers]]></title>
    <link href="http://benscheirman.com/2012/01/careful-with-block-based-notification-handlers/"/>
    <updated>2012-01-11T16:27:00+00:00</updated>
    <id>http://benscheirman.com/2012/01/careful-with-block-based-notification-handlers</id>
    <content type="html"><![CDATA[<p>In general, I prefer using block-based APIs over those that accept selectors.</p>

<p>The block based APIs are generally easier to read &amp; follow, and don&#8217;t clutter up your class with methods that are
out of context with the code that might potentially invoke them.</p>

<h2>An Example</h2>

<p>One good example is view animations.  Here we&#8217;re fading out a view and removing it from the hierarchy once
the view has been completely faded out.  It&#8217;s concise, easy to read, and you don&#8217;t need to go anywhere else in the
class to get a complete picture of how this works.</p>

<p>Also, since you can have multiple animations going on, having a block-based completion handler means
you don&#8217;t have to distinguish between what the animations were in some generic completion method.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="p">[</span><span class="n">UIView</span> <span class="nl">animateWithDuration:</span><span class="mf">0.5</span> <span class="nl">animations:</span><span class="o">^</span><span class="p">{</span>
</span><span class='line'>  <span class="n">someView</span><span class="p">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span> <span class="nl">completion:</span><span class="o">^</span> <span class="p">(</span><span class="kt">BOOL</span> <span class="n">finished</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[</span><span class="n">someView</span> <span class="n">removeFromSuperView</span><span class="p">];</span>
</span><span class='line'><span class="p">}];</span>
</span></code></pre></td></tr></table></div></figure>


<p>Contrast this with the non-block version:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">fadeOutView</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[</span><span class="n">UIView</span> <span class="n">beginAnimations</span><span class="p">];</span>
</span><span class='line'>  <span class="p">[</span><span class="n">UIView</span> <span class="nl">setAnimationDuration:</span><span class="mf">0.5</span><span class="p">];</span>
</span><span class='line'>  <span class="p">[</span><span class="n">UIView</span> <span class="nl">setAnimationDelegate:</span><span class="n">self</span><span class="p">];</span>
</span><span class='line'>  <span class="p">[</span><span class="n">UIView</span> <span class="nl">setAnimationDidStopSelector:</span><span class="k">@selector</span><span class="p">(</span><span class="nl">animationDidStop:finished:context:</span><span class="p">)];</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">someView</span><span class="p">.</span><span class="n">alpha</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>  <span class="p">[</span><span class="n">UIView</span> <span class="n">commitAnimations</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nl">animationDidStop:</span><span class="p">(</span><span class="n">NSString</span> <span class="o">*</span><span class="p">)</span><span class="n">animationID</span> <span class="nl">finished:</span><span class="p">(</span><span class="n">NSNumber</span> <span class="o">*</span><span class="p">)</span><span class="n">finished</span> <span class="nl">context:</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="p">)</span><span class="n">context</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[</span><span class="n">someView</span> <span class="n">removeFromSuperView</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<h2>Block-Based Notification Handlers</h2>

<p><code>NSNotificationCenter</code> also got some block love when iOS SDK 4.0 came around.  The old form looked like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">setupNotifications</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[[</span><span class="n">NSNotificationCenter</span> <span class="n">defaultCenter</span><span class="p">]</span> <span class="nl">addObserver:</span><span class="n">self</span>
</span><span class='line'>                                           <span class="nl">selector:</span><span class="k">@selector</span><span class="p">(</span><span class="nl">onWhizBang:</span><span class="p">)</span>
</span><span class='line'>                                               <span class="nl">name:</span><span class="n">MyWhizBangnotification</span>
</span><span class='line'>                                             <span class="nl">object:</span><span class="nb">nil</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nl">onWhizBang:</span><span class="p">(</span><span class="n">NSNotification</span> <span class="o">*</span><span class="p">)</span><span class="n">notification</span> <span class="p">{</span>
</span><span class='line'>  <span class="c1">// reload the table to show the new whiz bangs</span>
</span><span class='line'>  <span class="p">[</span><span class="n">self</span><span class="p">.</span><span class="n">tableView</span> <span class="n">reloadData</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">dealloc</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[[</span><span class="n">NSNotificationCenter</span> <span class="n">defaultCenter</span><span class="p">]</span> <span class="nl">removeObserver:</span><span class="n">self</span><span class="p">];</span>
</span><span class='line'>  <span class="p">[</span><span class="n">super</span> <span class="n">dealloc</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>This isn&#8217;t a lot of code (and it is easy to remember, unlike the previous UIView animation block code), however
the action and the notification handler are separated from each other.</p>

<p>The block-based API looks like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">setupNotifications</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[[</span><span class="n">NSNotificationCenter</span> <span class="n">defaultCenter</span><span class="p">]</span>
</span><span class='line'>      <span class="nl">addObserverForNotificationName:</span><span class="n">MyWhizBangNotification</span>
</span><span class='line'>                              <span class="nl">object:</span><span class="nb">nil</span>
</span><span class='line'>                               <span class="nl">queue:</span><span class="p">[</span><span class="n">NSOperationQueue</span> <span class="n">mainQueue</span><span class="p">]</span>
</span><span class='line'>                               <span class="nl">block:</span><span class="o">^</span><span class="p">(</span><span class="n">NSNotification</span> <span class="o">*</span><span class="n">notification</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>                                 <span class="c1">//reload the table to show the new whiz bangs</span>
</span><span class='line'>                                 <span class="p">[</span><span class="n">self</span><span class="p">.</span><span class="n">tableView</span> <span class="n">reloadData</span><span class="p">];</span>
</span><span class='line'>                               <span class="p">}];</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'>
</span><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">dealloc</span> <span class="p">{</span>
</span><span class='line'>  <span class="p">[[</span><span class="n">NSNotificationCenter</span> <span class="n">defaultCenter</span><span class="p">]</span> <span class="nl">removeObserver:</span><span class="n">self</span><span class="p">];</span>
</span><span class='line'>  <span class="p">[</span><span class="n">super</span> <span class="n">dealloc</span><span class="p">];</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Aside from some funky indentation, this is preferable in some cases, especially when the action to
be completed is as simple as reloading the table.</p>

<p>But there&#8217;s a bug.  Can you spot it?</p>

<h2>Blocks Are Closures</h2>

<p>There&#8217;s a subtle bug here that you might not notice at first.  I didn&#8217;t realize this until it was littered all
over my code base.</p>

<p>Blocks are <a href="http://simple.wikipedia.org/wiki/Closure_(computer_science)">closures</a>, and they will capture any values declared outside the scope of the block (and retained) so that
they can be used when the block executes.  This includes variables declared in the enclosing method or any ivars
that you reference from inside the block.</p>

<p>Here, we used <code>self.tableView</code>.  <code>self</code> gets retained by the block, which is also retained by self.  We have a <em>retain-cycle</em>
which is generally a bad thing.  It&#8217;s especially bad here, because we don&#8217;t clear out the block until <code>dealloc</code>,
but <em>dealloc won&#8217;t ever be called because the block is retaining the instance</em>!</p>

<h2>Weak Pointers Save the Day</h2>

<p>If you&#8217;ve read up on blocks, you&#8217;ve probably seen the <code>__block</code> keyword.  This specifier tells blocks not to retain the pointer.
So all we need is a new pointer, like so:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="n">__block</span> <span class="n">MyViewController</span> <span class="o">*</span><span class="n">weakSelf</span> <span class="o">=</span> <span class="n">self</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'><span class="c1">// use weakSelf in the blocks, instead of self</span>
</span></code></pre></td></tr></table></div></figure>


<p>This sort of code drives me nuts.  It won&#8217;t be apparent to the next developer why it&#8217;s there, and it&#8217;s
pretty ugly.</p>

<h2>Retain Cycles are Elsewhere, Too</h2>

<p>You might also run into this if you have a parent-child view controller relationship, or perhaps a
an parent->object->delegate chain, where the parent <em>is</em> the delegate.  This is why you typically mark
your delegate property signatures with <code>assign</code> instead of <code>retain</code> semantics.</p>

<p>Not all retain-cycles are terrible though.  If you have a way of breaking the cycle, then you just need
to weigh how long these objects will remain active for to decide if you need to fix it.</p>

<p>Hopefully this will save you a few headaches down the line.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Formatting JSON From Terminal]]></title>
    <link href="http://benscheirman.com/2011/12/formatting-json-from-terminal/"/>
    <updated>2011-12-12T15:08:00+00:00</updated>
    <id>http://benscheirman.com/2011/12/formatting-json-from-terminal</id>
    <content type="html"><![CDATA[<p>I work with JSON APIs a lot. On a current API I work on, there is an OAuth-esque request
signing process that is required to make sure that others cannot forge requests simply
by changing parameters arround.</p>

<p>A typical request might look like this:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>HTTP 1.1
</span><span class='line'>GET /foo/bars.json
</span><span class='line'>
</span><span class='line'>Headers:
</span><span class='line'>    Accept-Encoding = gzip;
</span><span class='line'>    Accept = application/json
</span><span class='line'>    Authorization = "cHOLIOb7bAeqFEmsz3io%2Bxg4sQA%3D";
</span><span class='line'>    Account-Id = 201;
</span><span class='line'>    User-Agent = "...";</span></code></pre></td></tr></table></div></figure>


<p>The <code>Authorization</code> header is generated by concatenating the HTTP Method, URL, any parameters, and then signed with a key.</p>

<p>Because of this security, it is very difficult to create adhoc requests just to try them out. So instead, we have our iPhone app
<code>NSLog</code> the proper curl command for us.  Now it&#8217;s as simple as copy &amp; paste from the Xcode Console, which gives me a
less-than-readable output of the JSON.</p>

<p>Usually for this I just pipe the command into <code>pbcopy</code> to get it on my clipboard, then I visit <a href="http://jsonlint.com">JSON Lint</a> to
make it easy to read.</p>

<h2>Doin&#8217; it all from Terminal</h2>

<p>I looked at ways of doing this all from the Terminal, and came across this python command:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>python -mjson.tool</span></code></pre></td></tr></table></div></figure>


<p>It takes input from stdin and outputs it formatted nicely.  Sweet!  Now all that&#8217;s needed is to make this a bit more easy to remember,
so I made a script to do this for me called <code>format_json</code> and put it in my path.</p>

<p>Now, any time I want to see the JSON output of an API, I can simply type:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='sh'><span class='line'><span class="nv">$ </span>curl some.server.com/api/devices.json?key<span class="o">=</span>124512312 -H Authorization:<span class="s2">&quot;124151231231123123&quot;</span> |
</span><span class='line'>    format_json
</span></code></pre></td></tr></table></div></figure>


<p>And here is the output:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="p">{</span>
</span><span class='line'>  <span class="s2">&quot;devices&quot;</span><span class="o">:</span> <span class="p">[</span>
</span><span class='line'>      <span class="p">{</span>
</span><span class='line'>          <span class="s2">&quot;device_id&quot;</span><span class="o">:</span> <span class="s2">&quot;40f4fc8a5818608dbb9a6c981179222b6f&quot;</span><span class="p">,</span>
</span><span class='line'>          <span class="s2">&quot;device_type&quot;</span><span class="o">:</span> <span class="s2">&quot;iPhone&quot;</span><span class="p">,</span>
</span><span class='line'>          <span class="s2">&quot;id&quot;</span><span class="o">:</span> <span class="mi">24</span><span class="p">,</span>
</span><span class='line'>          <span class="s2">&quot;name&quot;</span><span class="o">:</span> <span class="s2">&quot;Ben&#39;s iPhone&quot;</span><span class="p">,</span>
</span><span class='line'>          <span class="s2">&quot;push_enabled&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
</span><span class='line'>          <span class="s2">&quot;push_token&quot;</span><span class="o">:</span> <span class="s2">&quot;a3a36......480c25fdf&quot;</span>
</span><span class='line'>      <span class="p">}</span>
</span><span class='line'>  <span class="p">]</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Very handy, indeed.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Houston Tech Fest 2011 Recap]]></title>
    <link href="http://benscheirman.com/2011/10/houston-tech-fest-2011-recap/"/>
    <updated>2011-10-17T10:27:00+00:00</updated>
    <id>http://benscheirman.com/2011/10/houston-tech-fest-2011-recap</id>
    <content type="html"><![CDATA[<p>Houston Tech Fest 2011 came and went, and yet again was a great success.
I believe it was the biggest one ever, with over 1,300 registrants.</p>

<p>I gave three talks:</p>

<ul>
<li><a href="http://speakerrate.com/talks/8761-rails-intrigue">Rails Intrigue</a></li>
<li><a href="http://speakerrate.com/talks/8744-introducing-a-new-feature-to-a-rails-app-from-beginning-to-end">Introducing a new feature to a Rails app using Cucumber</a> (with Claudio Lasalla)</li>
<li><a href="http://speakerrate.com/talks/8760-wrangle-your-source-like-a-boss-with-git">Wrangle your source like a boss with git</a></li>
</ul>


<p>You can find the slides &amp; code used in the presentations <a href="http://github.com/subdigital/houston-tech-fest-2011">here on github</a>.</p>

<p>If you attended any of these sessions, I&#8217;d really appreciate if you
rate them using the links above.</p>

<p>See you next year, Houston Tech Fest!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Appsites Is Now AppKickstand]]></title>
    <link href="http://benscheirman.com/2011/10/appsites-is-now-appkickstand/"/>
    <updated>2011-10-13T21:50:00+00:00</updated>
    <id>http://benscheirman.com/2011/10/appsites-is-now-appkickstand</id>
    <content type="html"><![CDATA[<p>A few weeks ago I launched Appsites, a free way to quickly host an
attractive splash page for iPhone applications.</p>

<p>Instead of competing with another site with the same name for traffic
when we could be sharing it, I decided a new name was in order.</p>

<p><strong>I now present to you:  <a href="http://appkickstand.com">AppKickstand</a>.</strong></p>

<p><a href="http://appkickstand.com"><img src="http://benscheirman.com/images/appkickstand.png"
alt="AppKickstand" border="0" /></a></p>

<p>For an example of what it looks like with real apps, check out
<a href="http://appkickstand.com/giggletouch">Giggle Touch</a> or
<a href="http://appkickstand.com/tallythings">Tally Things</a>.</p>

<p>If you have an iPhone app, what are you waiting for?  It&#8217;s <strong>FREE</strong>!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sharing Vim Configuration Between Machines]]></title>
    <link href="http://benscheirman.com/2011/10/sharing-vim-configuration-between-machines/"/>
    <updated>2011-10-06T09:29:00+00:00</updated>
    <id>http://benscheirman.com/2011/10/sharing-vim-configuration-between-machines</id>
    <content type="html"><![CDATA[<p>I do most of my development on my MacBook Pro, however I have a nice 27&#8221;
iMac at home, and it is refreshing to use it for development when I can.
It&#8217;s fast and has a huge screen.  The only downside is all my custom
development configurations are on my MacBook Pro!</p>

<p>There are a number of options you can use to share settings between
machines, but I&#8217;m a fan of using <a href="http://dropbox.com">Dropbox</a> (<a href="http://db.tt/sYjPEQl">referral link</a>). Any change I make, on either machine, will get automatically
synchronized for me.</p>

<p>Since my Vim configurations were already present on my MacBook Pro, the
first step was to copy them over to a Dropbox folder:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>mkdir ~/Dropbox/vim
</span><span class='line'>cp -R ~/.vim ~/Dropbox/vim
</span><span class='line'>cp ~/.vimrc ~/Dropbox/vim
</span><span class='line'>cp ~/.vimrc.local ~/Dropbox/vim
</span><span class='line'>cp ~/.gvimrc ~/Dropbox/vim</span></code></pre></td></tr></table></div></figure>


<p>The next step was to come up with an installer script that would symlink
these files on a new machine.  I made sure to move existing vim files to
a temporary filename so that I wouldn&#8217;t lose anything accidentally.</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>set -o errexit
</span><span class='line'>
</span><span class='line'>function confirm()
</span><span class='line'>{
</span><span class='line'>    echo -n "$@ "
</span><span class='line'>    read -e answer
</span><span class='line'>    for response in y Y yes YES Yes Sure sure SURE OK ok Ok
</span><span class='line'>    do
</span><span class='line'>        if [ "_$answer" == "_$response" ]
</span><span class='line'>        then
</span><span class='line'>            return 0
</span><span class='line'>        fi
</span><span class='line'>    done
</span><span class='line'>
</span><span class='line'>    # Any answer other than the list above is considerred a "no" answer
</span><span class='line'>    return 1
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>function link_file() 
</span><span class='line'>{
</span><span class='line'>  echo "symlinking $1"
</span><span class='line'>  ln -s "$PWD/$1" "$HOME/$1"
</span><span class='line'>}
</span><span class='line'>
</span><span class='line'>echo "This will remove any existing vim configuration files and simlink them with the files here."
</span><span class='line'>confirm "Are you sure?"
</span><span class='line'>if [ $? -eq 0 ]
</span><span class='line'>then
</span><span class='line'>  for file in ~/.vimrc ~/.vimrc.local ~/.gvimrc
</span><span class='line'>  do
</span><span class='line'>    if [[ -f $file ]]; then
</span><span class='line'>      echo "Moving $file to $file.bak"
</span><span class='line'>      mv $file $file.bak
</span><span class='line'>    fi
</span><span class='line'>  done
</span><span class='line'>
</span><span class='line'>  for dir in ~/.vim
</span><span class='line'>  do
</span><span class='line'>    if [[ -d $dir ]]; then
</span><span class='line'>      echo "Moving $dir directory to $dir.bak"
</span><span class='line'>      mv $dir $dir.bak
</span><span class='line'>    fi
</span><span class='line'>  done
</span><span class='line'>fi
</span><span class='line'>
</span><span class='line'>echo "symlinking"
</span><span class='line'>
</span><span class='line'>for file in .vim .vimrc .vimrc.local .gvimrc
</span><span class='line'>do
</span><span class='line'>  link_file $file
</span><span class='line'>done
</span><span class='line'>
</span><span class='line'>echo "Done.  Check that it works.  If so, you can remove the .bak files, if any"
</span></code></pre></td></tr></table></div></figure>


<p>Make sure the script is executable by running:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>chmod +x setup.sh</span></code></pre></td></tr></table></div></figure>


<p>Then run this script on any new machine that you want to use Vim on. It will symlink these files from your Dropbox folder to your home
folder:</p>

<ul>
<li><code>.vim/</code></li>
<li><code>.vimrc</code></li>
<li><code>.vimrc.local</code></li>
<li><code>.gvimrc</code></li>
</ul>


<p>After it&#8217;s done, check that it is working.  Remove any .bak files that
you don&#8217;t need anymore.</p>

<p>And that&#8217;s it. You have an automatic Vim configuration synching system
between machines.  It works great for your shell configuration as well!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Making a UIButton Flip Over]]></title>
    <link href="http://benscheirman.com/2011/10/making-a-uibutton-flip-over/"/>
    <updated>2011-10-04T08:44:00+00:00</updated>
    <id>http://benscheirman.com/2011/10/making-a-uibutton-flip-over</id>
    <content type="html"><![CDATA[<p>If you&#8217;ve used the iPod app on the iPhone, you&#8217;ve probably seen an
interesting trick when switching from album art to the track listing:
the button in the top right corner flips over synchronized with the flip
animation of the main view.</p>

<p>I wanted to achieve a similar effect for the iPhone app that I&#8217;m
building, Deli Radio (<a href="http://itunes.com/apps/deliradio">app store link</a>).</p>

<p>If you&#8217;ve ever struggled with the flip transitions before, you probably
know how finicky it can be to get it all working. The best way to set it
up is to have a parent view contain both views that you want to swap,
and set the animation transition type on <em>that</em> view.</p>

<p>For a button (either in the navigation bar or elsewhere) we&#8217;d need to
introduce a parent view to achieve this effect.  This is how I achieved
the effect.</p>

<p><img class="right" src="http://benscheirman.com/images/btn-info-border@2x.png">
<img class="right" src="http://benscheirman.com/images/btn-images@2x.png"></p>

<p>First, I had two images I wanted to use for my <code>UIBarButtonItem</code>.</p>

<p>I wanted this to be easily reusable (since I need to do this in more
than one place in this application), so I created a category method on
<code>UIButton</code>.</p>

<div><script src='https://gist.github.com/1261810.js?file=UIButtonCHButtonFlip.h'></script>
<noscript><pre><code>@interface UIButton (CHFlipButton)

+ (UIView *)flipButtonWithFirstImage:(UIImage *)firstImage 
                         secondImage:(UIImage *)secondImage
                     firstTransition:(UIViewAnimationTransition)firstTransition
                    secondTransition:(UIViewAnimationTransition)secondTransition
                      animationCurve:(UIViewAnimationCurve)curve
                            duration:(NSTimeInterval)duration
                              target:(id)target
                            selector:(SEL)selector;


@end
</code></pre></noscript></div>


<p>It may look strange that a <code>UIButton</code> class method returns a <code>UIView</code>
instance, but we need to have a container view to base the animations
off of.</p>

<p>Here is the implementation:</p>

<div><script src='https://gist.github.com/1261810.js?file=UIButtonCHButtonFlip.m'></script>
<noscript><pre><code>#import &lt;objc/runtime.h&gt;

#import &quot;UIButton+CHFlipButton.h&quot;

// keys used for assigning associated objects
static char UIButtonFlipBlockKey;
static char UIButtonFlipAltButtonKey;
static char UIButtonFlipTransitionKey;
static char UIButtonFlipContainerViewKey;

typedef void (^UIButtonFlipActionBlock)(id sender);

@implementation UIButton (CHFlipButton)

// associate the block with the button instance, then set the default button handler

- (void)chFlipButton_handleControlEvent:(UIControlEvents)event withBlock:(UIButtonFlipActionBlock)block {
    objc_setAssociatedObject(self, &amp;UIButtonFlipBlockKey, block, OBJC_ASSOCIATION_COPY);
    [self addTarget:self action:@selector(chFlipButton_callFlipBlock:) forControlEvents:UIControlEventTouchUpInside];
}

// the default button handler just calls the block

- (void)chFlipButton_callFlipBlock:(id)sender {
    UIButtonFlipActionBlock block = objc_getAssociatedObject(self, &amp;UIButtonFlipBlockKey);
    if (block) {
        block(sender);
    }
}

+ (UIView *)flipButtonWithFirstImage:(UIImage *)firstImage 
                         secondImage:(UIImage *)secondImage
                     firstTransition:(UIViewAnimationTransition)firstTransition
                    secondTransition:(UIViewAnimationTransition)secondTransition
                      animationCurve:(UIViewAnimationCurve)curve
                            duration:(NSTimeInterval)duration
                              target:(id)target
                            selector:(SEL)selector {
    
    UIButtonFlipActionBlock flipButtonAction = ^(id sender) { /* shown further down */ };
    
    //create the first button
    UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button1 setBackgroundImage:firstImage forState:UIControlStateNormal];
    [button1 chFlipButton_handleControlEvent:UIControlEventTouchUpInside withBlock:flipButtonAction];
    [button1 setFrame:CGRectMake(0, 0, firstImage.size.width, firstImage.size.height)];

    //create the 2nd button
    UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [button2 setBackgroundImage:secondImage forState:UIControlStateNormal];
    [button2 chFlipButton_handleControlEvent:UIControlEventTouchUpInside withBlock:flipButtonAction];
    [button2 setFrame:CGRectMake(0, 0, secondImage.size.width, secondImage.size.height)];    
 
    //create a container to hold them
    UIView *container = [[[UIView alloc] initWithFrame:button1.bounds] autorelease];
    [container addSubview:button1];
    
    //record state so we can access it later (in the block)
    objc_setAssociatedObject(button1, &amp;UIButtonFlipAltButtonKey, button2, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    objc_setAssociatedObject(button1, &amp;UIButtonFlipTransitionKey, [NSNumber numberWithInt:firstTransition], OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    objc_setAssociatedObject(button1, &amp;UIButtonFlipContainerViewKey, container, OBJC_ASSOCIATION_ASSIGN);
    
    objc_setAssociatedObject(button2, &amp;UIButtonFlipAltButtonKey, button1, OBJC_ASSOCIATION_ASSIGN);
    objc_setAssociatedObject(button2, &amp;UIButtonFlipTransitionKey, [NSNumber numberWithInt:secondTransition], OBJC_ASSOCIATION_ASSIGN);  //button1 is in charge of the retains initially
    objc_setAssociatedObject(button2, &amp;UIButtonFlipContainerViewKey, container, OBJC_ASSOCIATION_ASSIGN);
    
    //returns the container, because this is what needs to be added to your view
    return container;
}

@end
</code></pre></noscript></div>


<p>I am using a little-known technique of setting associated objects
using <code>objc_setAssociatedObject(...)</code>.  This uses the runtime to attach
state to an existing class without needing to subclass.</p>

<p>Now that you understand how it is all setup, the block body will now
make sense:</p>

<div><script src='https://gist.github.com/1261810.js?file=UIButtonCHButtonFlipBlock.m'></script>
<noscript><pre><code>/* Here is that block definition from above */

    UIButtonFlipActionBlock flipButtonAction = ^(id sender) {

        //get the alternate button &amp; container
        UIButton *otherButton = (UIButton *)objc_getAssociatedObject(sender, &amp;UIButtonFlipAltButtonKey);
        UIView *container = (UIView *)objc_getAssociatedObject(sender, &amp;UIButtonFlipContainerViewKey);
        
        //figure out our transition
        NSNumber *transitionNumber = (NSNumber *)objc_getAssociatedObject(sender, &amp;UIButtonFlipTransitionKey);
        UIViewAnimationTransition transition = (UIViewAnimationTransition)[transitionNumber intValue];
                
        [UIView animateWithDuration:duration animations:^ {
            
            [UIView setAnimationTransition:transition forView:container cache:YES];
            [UIView setAnimationCurve:curve];
            
            //the view has the last retain count on the sender button, so we need to retain it first
            objc_setAssociatedObject(otherButton, &amp;UIButtonFlipAltButtonKey, sender, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
            
            [sender removeFromSuperview];
            [container addSubview:otherButton];
            
            //sender no longer needs to retain the other button, because the view now is...
            objc_setAssociatedObject(sender, &amp;UIButtonFlipAltButtonKey, otherButton, OBJC_ASSOCIATION_ASSIGN);
            
        }];
        
        //call the original button handler
        [target performSelector:selector withObject:self];
    };
</code></pre></noscript></div>


<p>Usage is really easy.  I just created a bar button item with a custom
view, and was done.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="n">UIImage</span> <span class="o">*</span><span class="n">firstImage</span>  <span class="o">=</span> <span class="p">[</span><span class="n">UIImage</span> <span class="nl">imageNamed:</span><span class="s">@&quot;btn-info.png&quot;</span><span class="p">];</span>
</span><span class='line'><span class="n">UIImage</span> <span class="o">*</span><span class="n">secondImage</span> <span class="o">=</span> <span class="p">[</span><span class="n">UIImage</span> <span class="nl">imageNamed:</span><span class="s">@&quot;btn-images.png&quot;</span><span class="p">];</span>
</span><span class='line'><span class="n">UIView</span> <span class="o">*</span><span class="n">container</span>    <span class="o">=</span> <span class="p">[</span><span class="n">UIButton</span> <span class="nl">flipButtonWithFirstImage:</span><span class="n">firstImage</span>
</span><span class='line'>                                              <span class="nl">secondImage:</span><span class="n">secondImage</span>
</span><span class='line'>                                          <span class="nl">firstTransition:</span><span class="n">UIViewAnimationTransitionFlipFromRight</span>
</span><span class='line'>                                         <span class="nl">secondTransition:</span><span class="n">UIViewAnimationTransitionFlipFromLeft</span>
</span><span class='line'>                                           <span class="nl">animationCurve:</span><span class="n">UIViewAnimationCurveEaseInOut</span>
</span><span class='line'>                                                 <span class="nl">duration:</span><span class="mf">0.8</span>
</span><span class='line'>                                                   <span class="nl">target:</span><span class="n">self</span>
</span><span class='line'>                                                 <span class="nl">selector:</span><span class="k">@selector</span><span class="p">(</span><span class="n">flipContent</span><span class="p">)];</span>
</span><span class='line'>
</span><span class='line'><span class="n">self</span><span class="p">.</span><span class="n">navigationItem</span><span class="p">.</span><span class="n">rightBarButtonItem</span> <span class="o">=</span> <span class="p">[[[</span><span class="n">UIBarButtonItem</span> <span class="n">alloc</span><span class="p">]</span>
</span><span class='line'>  <span class="nl">initWithCustomView:</span><span class="n">container</span><span class="p">]</span> <span class="n">autorelease</span><span class="p">];</span>
</span></code></pre></td></tr></table></div></figure>


<p>The effect can be seen below.</p>

<p><video width='389' height='336' preload='none' controls poster='https://flux88.s3.amazonaws.com/videos/button_flip1.jpeg'><source src='https://flux88.s3.amazonaws.com/videos/button_flip.m4v' ></video></p>

<p>Note that the flip effect on the main view is achieved separately, but
the 2 strategies share identical values for the animation, so the flip
transition types match, as well as the duration &amp; animation curve.</p>

<p>The code for this can be seen in the <a href="https://github.com/chaione/chaioneui">ChaiOneUI project on Github</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Creating a Glow Effect for UILabel and UIButton]]></title>
    <link href="http://benscheirman.com/2011/09/creating-a-glow-effect-for-uilabel-and-uibutton/"/>
    <updated>2011-09-27T19:57:00+00:00</updated>
    <id>http://benscheirman.com/2011/09/creating-a-glow-effect-for-uilabel-and-uibutton</id>
    <content type="html"><![CDATA[<p>One recent iPhone design mockup called for a glowing effect for a
<code>UIButton</code>.</p>

<p>This can be accomplished with images, however I needed a series of
buttons to have the same glow effect, and it can easily be accomplished
with Core Graphics.</p>

<p>The first step is to include the Core Graphics headers:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="cp">#import &lt;QuartzCore/QuartzCore.h&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Next, the effect is achieved by using a shadow with no offset (meaning
the shadow will be directly underneath the text, not shifted down or to
the right).  The layer is then given a shadow radius &amp; opacity to allow
the shadow to bleed outward.  Unsetting <code>masksToBounds</code> will allow the
glow to be drawn even outside of the label&#8217;s frame. Finally the shadow color is set to either the
foreground color or something a bit lighter.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="n">UIColor</span> <span class="o">*</span><span class="n">color</span> <span class="o">=</span> <span class="n">button</span><span class="p">.</span><span class="n">currentTitleColor</span><span class="p">;</span>
</span><span class='line'><span class="n">button</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">layer</span><span class="p">.</span><span class="n">shadowColor</span> <span class="o">=</span> <span class="p">[</span><span class="n">color</span> <span class="n">CGColor</span><span class="p">];</span>
</span><span class='line'><span class="n">button</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">layer</span><span class="p">.</span><span class="n">shadowRadius</span> <span class="o">=</span> <span class="mf">4.0f</span><span class="p">;</span>
</span><span class='line'><span class="n">button</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">layer</span><span class="p">.</span><span class="n">shadowOpacity</span> <span class="o">=</span> <span class="mf">.9</span><span class="p">;</span>
</span><span class='line'><span class="n">button</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">layer</span><span class="p">.</span><span class="n">shadowOffset</span> <span class="o">=</span> <span class="n">CGSizeZero</span><span class="p">;</span>
</span><span class='line'><span class="n">button</span><span class="p">.</span><span class="n">titleLabel</span><span class="p">.</span><span class="n">layer</span><span class="p">.</span><span class="n">masksToBounds</span> <span class="o">=</span> <span class="n">NO</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>This effect works on plain <code>UILabel</code> or the <code>titleLabel</code> property of a
<code>UIButton</code>.  You can see the results of the effect here:</p>

<p><img class="image" src="http://benscheirman.com/images/uibutton-gloweffect.png"></p>

<p>Don&#8217;t go overboard with this.  It&#8217;s a subtle effect, but looks great
when used effectively.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Introducing App Sites]]></title>
    <link href="http://benscheirman.com/2011/09/introducing-appsites/"/>
    <updated>2011-09-20T08:46:00+00:00</updated>
    <id>http://benscheirman.com/2011/09/introducing-appsites</id>
    <content type="html"><![CDATA[<p>I&#8217;ve not been that great about marketing Giggle Touch.  It&#8217;s a cool app,
kids like it, but most people don&#8217;t know about it.</p>

<p>The biggest reason was probably that I never set up a proper website for
it.  Doing a search would only yield a blog post that said it was
&#8220;coming soon.&#8221;</p>

<p>That&#8217;s all changed now.  I&#8217;d like to introduce <em>App Sites</em>.</p>

<h2><a href="http://appsites.heroku.com">App Sites</a></h2>

<p><img class="right" src="http://benscheirman.com/images/yourapphere.png"></p>

<p>The premise is simple: <em>standup a website for an iPhone
app in minutes</em>.</p>

<p>Check it out here:
<a href="http://appsites.heroku.com">http://appsites.heroku.com</a>.</p>

<p>You can see the site in action by visiting the
<a href="http://appsites.heroku.com/giggletouch">Giggle Touch</a> page.</p>

<p>It&#8217;s free (for now) and gives you the ability to add features, a
description, a link back to the app, and a screenshot.</p>

<p>Planned upcoming features include:</p>

<ul>
<li>Custom domains</li>
<li>Multiple screenshots</li>
<li>Videos</li>
<li>Coming soon (if the app hasn&#8217;t launched yet)</li>
<li>More analytics</li>
</ul>


<p>If you have an iPhone app, I encourage you to create a page.  Let me
know what you think!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Firebug-Style Visual Debugging for iOS]]></title>
    <link href="http://benscheirman.com/2011/09/firebug-style-debugging-for-ios/"/>
    <updated>2011-09-16T10:56:00+00:00</updated>
    <id>http://benscheirman.com/2011/09/firebug-style-debugging-for-ios</id>
    <content type="html"><![CDATA[<p>Using a crazy helpful library called <a href="https://github.com/domesticcatsoftware/DCIntrospect">DC Introspect</a> you&#8217;re able to easily take an app running in the Simulator:</p>

<p><img class="image" src="http://benscheirman.com/images/simulator-before-introspection.png"></p>

<p>And get visual frame debugging information like this:</p>

<p><img class="image" src="http://benscheirman.com/images/simulator-after-introspection.png"></p>

<p>You can also click &amp; drag your mouse to get pixel information,
surrounding frames, print out detailed frame information in the console,
and even move frames around all while the app is running.</p>

<p>Using it is incredibly simple:</p>

<ul>
<li>Make sure you have <code>DEBUG</code> defined in your Preprocessor Macros:</li>
</ul>


<p><img class="image" src="http://benscheirman.com/images/debug-preprocessor-macro.png"></p>

<ul>
<li><p>Download the code from https://github.com/domesticcatsoftware/DCIntrospect and drag the DCIntrospect/DCIntrospect folder into your project</p></li>
<li><p>In your Application Delegate class, make the following changes:</p></li>
</ul>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="cp">    #import &quot;DCIntrospect.h&quot;</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="c1">// in applicationDidFinishLaunching:</span>
</span><span class='line'>
</span><span class='line'><span class="p">[</span><span class="n">self</span><span class="p">.</span><span class="n">window</span> <span class="n">makeKeyAndVisible</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'><span class="cp">#ifdef TARGET_IPHONE_SIMULATOR</span>
</span><span class='line'>    <span class="p">[[</span><span class="n">DCIntrospect</span> <span class="n">sharedIntrospector</span><span class="p">]</span> <span class="n">start</span><span class="p">];</span>
</span><span class='line'><span class="cp">#endif</span>
</span></code></pre></td></tr></table></div></figure>


<p>Once that is done, the library will be loaded and you can use it.  When
the simulator launches, just press Spacebar to activate the tool.</p>

<p>Here are some keyboard shortcuts:</p>

<ul>
<li><code>o</code> - Outline all views</li>
<li><code>?</code> - Prints out a help view</li>
<li><code>f</code> - Flash on <code>drawRect:</code> calls</li>
<li><code>c</code> - Toggle showing coordinates</li>
<li><code>4 6 8 2</code> - Nudge the selected view left, right, up, down</li>
<li><code>0</code> - Recenter view where it was originally</li>
<li><code>9 7 3 1</code> - Modify Width &amp; Height of selected view</li>
</ul>


<p>You can also click &amp; drag with the mouse to get detailed information
about frames &amp; mouse position.</p>

<p>I am amazed at how awesome this library is. I&#8217;ll be using it in my
default toolbox from now on.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Vim - Could Not Invoke JSLint]]></title>
    <link href="http://benscheirman.com/2011/08/vim---could-not-invoke-jslint/"/>
    <updated>2011-08-26T08:59:00+00:00</updated>
    <id>http://benscheirman.com/2011/08/vim&#8212;could-not-invoke-jslint</id>
    <content type="html"><![CDATA[<p>If you&#8217;re running MacVim with Janus and have upgraded to Lion, you may
have noticed a little error when you open JavaScript files:</p>

<blockquote><p>Error detected while processing function 87_JSLint:
Line 33:
could not invoke JSLint!</p></blockquote>

<p>It seems many are having <a href="https://github.com/hallettj/jslint.vim/issues/13">this issue</a>.  There are 2 things to check:</p>

<ol>
<li>Make sure you have Node in your path.  Confirm this by typing <code>which
node</code> and make sure it resolves a binary somewhere on your system.</li>
<li>Open up your <code>~/.vimrc.local</code> and add this command:</li>
</ol>


<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="c">&quot; Use Node.js for JavaScript interpretation</span>
</span><span class='line'><span class="k">let</span> $JS_CMD<span class="p">=</span><span class="s1">&#39;node&#39;</span>
</span></code></pre></td></tr></table></div></figure>


<p>Kudos to <a href="http://github.com/eventualbuddha">eventualbuddha</a> for
figuring this out.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Is Rails Exempt?]]></title>
    <link href="http://benscheirman.com/2011/08/is-rails-exempt-from-software-principles/"/>
    <updated>2011-08-26T07:58:00+00:00</updated>
    <id>http://benscheirman.com/2011/08/is-rails-exempt-from-software-principles</id>
    <content type="html"><![CDATA[<p>If you&#8217;ve been following the Ruby community recently, you&#8217;d notice that
there&#8217;s are people calling our Rails (and Rails developers) for treating
Rails as if it is somehow <em>exempt</em> from long-standing software
principles.</p>

<p><a href="http://osherove.com/">Roy Osherove</a>, a fairly well-known .NET developer and author of The <a href="http://artofunittesting.com/">Art of Unit Testing</a>, ventured into Ruby-land
recently and commented on twitter about how Rails&#8217;s
definition of unit &amp; integration is quite different from his.</p>

<p><img class="tweet" src="http://benscheirman.com/images/rails-unit-integration-tweet.png"></p>

<p>I have to agree with Roy. Those in the TDD camp in .NET understood the
difference and were (from my experience) fairly cognizent of isolating
concerns and not mixing the 2 concepts. Some even go as far as to
isolate integration tests into their own assembly, providing a physical
separation further guaranteeing that a unit test project won&#8217;t touch
web services or the database.</p>

<p>It&#8217;s easy to assume from the outside that the Rails is just testing
nirvana and that <em>everyone</em> does it and it&#8217;s so easy.  Unfortunately it&#8217;s
just not the truth.  Rails (and Ruby) make testing really easy but that
means it&#8217;s even easier to do the wrong thing as well.</p>

<h2>Legacy Rails Apps</h2>

<p>Now that Rails is (gasp) over 7 years old you&#8217;re starting to see some
real legacy Rails applications out in the wild.</p>

<p><a href="http://twitter.com/avdi">Avdi Grimm</a> has a <a href="http://avdi.org/devblog/2011/08/22/your-code-is-my-hell/">good post</a> on the topic of how many of the Rails apps he comes to work on are in poor shape, technically.</p>

<blockquote><p>Here are a few examples, just to give you an idea of what I’m talking about:</p>

<p>“Design Patterns are a Java thing. In Ruby you just write code.”</p>

<p>“The warnings Ruby produces are dumb; just disable them.”</p>

<p>“Sure they aren’t technically Unit Tests, but isolating objects turned out to be kind of hard and besides nobody else is doing it.”</p>

<p>“Stuff like the Law of Demeter isn’t really as important in Ruby code”</p>

<p>“That’s only a problem in large projects” (implying that this project will never become large).</p></blockquote>

<p>I&#8217;ve certainly been guilty of some of this. Rails makes it easy to do
things that can turn out to be problematic. As with anything, you have
to be disciplined to notice the warning signs and act accordingly.</p>

<p>When testing is painful, you&#8217;re likely making mistakes. Some common
pain-points that I&#8217;ve experienced are:</p>

<ul>
<li>No tests - the app is hard to test because the design is poor. Classes
are too tightly coupled and don&#8217;t have clear delineation of
responsibilities.</li>
<li>Tests break for unrelated reasons - the tests are covering too much
behavior, so when a single behavior changes, many tests break.</li>
<li>Tests break when implementation changes - the tests are probably
utilizing too much mocking &amp; stubbing. The tests are coupled heavily
to a particular implementation.</li>
<li>Unclear what the problem is when a test breaks - Tests are probably
too coarse-grained and may contain too many assertions per test.</li>
</ul>


<p>These are just a sampling of what I&#8217;ve personally observed.</p>

<p>So why do many Rails developers ignore these concepts?</p>

<h2>Pragmatism at work</h2>

<p>Many rails tutorials (and the default Rails template) treats model tests
as <em>unit</em> tests. Since Rails models are by default based on Active
Record, they have data access baked into their core.  Doing proper unit
testing means you&#8217;re testing a logical unit.  If your test involves a
model operation that requires a database round-trip, that&#8217;s technically
an <em>integration</em> test.  But does it really matter?</p>

<p>Most Rails developers will tell you no. Consider this spec:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">describe</span> <span class="no">Post</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">it</span> <span class="s2">&quot;should be initially unpublished&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="no">Post</span><span class="o">.</span><span class="n">new</span><span class="o">.</span><span class="n">published</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="kp">false</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This is a unit test. It tests a single piece of functionality and will
fail for just one reason.</p>

<p>Now, here&#8217;s another example:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">it</span> <span class="s2">&quot;should fetch published articles&quot;</span> <span class="k">do</span>
</span><span class='line'>  <span class="c1"># ?</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>




<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1"># post.rb</span>
</span><span class='line'><span class="k">class</span> <span class="nc">Post</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
</span><span class='line'>  <span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">published</span>
</span><span class='line'>    <span class="n">where</span><span class="p">(</span><span class="s2">&quot;published_at &lt;= ?&quot;</span><span class="p">,</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span><span class="p">)</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>How should you implement this spec?</p>

<p>If you were trying to avoid hitting the database you might intercept the
<code>where</code> call and assert the parameters passed to it. But surely this
isn&#8217;t the only way you could implement this method giving the same
behavior.  You might use <code>scopes</code> or another <code>where</code> call might actually
be added later that doesn&#8217;t affect the outcome of this method in any way
that this test is concerned about.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">it</span> <span class="s2">&quot;should fetch published articles&quot;</span> <span class="k">do</span>
</span><span class='line'>  <span class="mi">3</span><span class="o">.</span><span class="n">times</span> <span class="p">{</span> <span class="no">Factory</span><span class="o">.</span><span class="n">create</span> <span class="ss">:article</span> <span class="p">}</span>
</span><span class='line'>  <span class="n">future_post</span> <span class="o">=</span> <span class="no">Factory</span><span class="o">.</span><span class="n">create</span> <span class="ss">:article</span><span class="p">,</span> <span class="ss">:published_at</span> <span class="o">=&gt;</span> <span class="mi">2</span><span class="o">.</span><span class="n">days</span><span class="o">.</span><span class="n">from_now</span>
</span><span class='line'>  <span class="n">posts</span> <span class="o">=</span> <span class="no">Post</span><span class="o">.</span><span class="n">published</span>
</span><span class='line'>  <span class="n">posts</span><span class="o">.</span><span class="n">size</span><span class="o">.</span><span class="n">should</span> <span class="o">==</span> <span class="mi">3</span>
</span><span class='line'>  <span class="n">post</span><span class="o">.</span><span class="n">should_not</span> <span class="kp">include</span> <span class="n">future_post</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This test hits the database (numerous times, in fact) but it&#8217;s testing
<em>exactly</em> the behavior we need.  We aren&#8217;t testing implementation, we&#8217;re
testing that the behavior works as intended.  If we somehow muck with
the query, breaking it, this test will fail.  If we change the
implementation to use some other query means (scopes or whatever) this
test will still pass.</p>

<p>Is it so bad that the test hits the database?</p>

<p>There are drawbacks of course:</p>

<ul>
<li>The test requires a database, thus you have to migrate</li>
<li>The <code>database_cleaner</code> gem will have to be present to clean out the
database before each run</li>
<li>These database statements make the test suite a LOT slower, so large
test suites will eventually suffer.</li>
<li>The tests could fail if the database isn&#8217;t present (or migrated), or
if the query is incorrect.  But this isn&#8217;t likely to happen since
we&#8217;re using a tested framework (ActiveRecord).</li>
</ul>


<p>Ultimately this isn&#8217;t really a unit test at all.  It&#8217;s an integration
test.  So is <code>spec/models/post_spec.rb</code> the wrong place for this stuff?</p>

<p>The question eventually comes down to this: <em>What is more valuable?  A
fast, isolated test suite?  Or a test suite that breaks for the right
reasons?</em></p>

<h2>Don&#8217;t throw out good practices just because it&#8217;s Ruby</h2>

<p>I think it&#8217;s important to be cognizant of software paradigms and use
them where they make sense. It&#8217;s also important to recognize when
practices are being ignored because &#8220;celebrities&#8221; aren&#8217;t touting them.</p>

<p>It is still valuable, however, to keep a fresh eye on old assumptions. Don&#8217;t
always take things as gospel just because that&#8217;s the way they have
always been. One
of the things I love about the Ruby community is how willing people are
to rock the boat &amp; try something new.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[When viewWillAppear: Isn't Called]]></title>
    <link href="http://benscheirman.com/2011/08/when-viewwillappear-isnt-called/"/>
    <updated>2011-08-24T10:11:00+00:00</updated>
    <id>http://benscheirman.com/2011/08/when-viewwillappear-isnt-called</id>
    <content type="html"><![CDATA[<p>The <code>UIViewController</code> lifecycle is pretty simple.  <code>viewDidLoad</code> is
called when the view is loaded (usually from a XIB) and when the view
controller&#8217;s view is about to be displayed <code>viewWillAppear:</code> gets called
(and <code>viewWillDisappear:</code> when it goes away).</p>

<p>The problem is, when you have a non-standard view hierarchy (like my
current app) these methods don&#8217;t get called. The Apple docs have this to
say about the problem:</p>

<blockquote><p>Warning: If the view belonging to a view controller is added to a view hierarchy directly, the view controller will not receive this message. If you insert or add a view to the view hierarchy, and it has a view controller, you should send the associated view controller this message directly. Failing to send the view controller this message will prevent any associated animation from being displayed.</p></blockquote>

<p>In my application I have a persistent bar at the bottom of the screen,
so my <code>UINavigationController</code> only owns a portion of the screen.  Thus, my
<code>RootViewController</code> (which owns these 2 portions) is always <em>active</em>.</p>

<p><img class="screenshot" src="http://benscheirman.com/images/non-standard-nav-frame.png"></p>

<p>I recently came upon a requirement that needed to leverage
<code>viewWillAppear:</code> and <code>viewWillDisappear:</code> in order to decorate the
bottom bar with some additional information. Since this is a view
controller a few layers deep in the hierarchy, the methods weren&#8217;t being
called.</p>

<p>Luckly, there is a fix to this. The navigation controller can notify
its <code>delegate</code> when it changes view controllers.</p>

<p>Start off in the view controller that is the root of the navigation
controller hierarchy.  Make it conform to the
<code>UINavigationControllerDelegate</code> protocol.  We&#8217;ll also need an ivar to
store the last view controller that <em>appeared</em> so that we can notify
when it <em>disappears</em>.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="k">@interface</span> <span class="nc">MyRootViewController</span> : <span class="nc">UIViewController</span>
</span><span class='line'>    <span class="o">&lt;</span><span class="n">UINavigationControllerDelegate</span><span class="o">&gt;</span> <span class="p">{</span>
</span><span class='line'>      <span class="n">UIViewController</span> <span class="o">*</span><span class="n">_lastViewController</span><span class="p">;</span>
</span><span class='line'><span class="p">}</span>
</span><span class='line'><span class="c1">// methods</span>
</span><span class='line'>
</span><span class='line'><span class="k">@end</span>
</span></code></pre></td></tr></table></div></figure>


<p>In the implementation, in do the following:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'>    <span class="k">@implementation</span> <span class="nc">MyRootViewController</span>
</span><span class='line'>
</span><span class='line'>    <span class="c1">// other stuff</span>
</span><span class='line'>
</span><span class='line'>    <span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="n">viewDidLoad</span> <span class="p">{</span>
</span><span class='line'>        <span class="p">[</span><span class="n">super</span> <span class="n">viewDidLoad</span><span class="p">];</span>
</span><span class='line'>
</span><span class='line'>        <span class="n">self</span><span class="p">.</span><span class="n">navigationController</span><span class="p">.</span><span class="n">delegate</span> <span class="o">=</span> <span class="n">self</span><span class="p">;</span>
</span><span class='line'>        <span class="c1">// ...</span>
</span><span class='line'>    <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>    <span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nl">navigationController:</span><span class="p">(</span><span class="n">UINavigationController</span> <span class="o">*</span><span class="p">)</span><span class="n">navigationController</span>
</span><span class='line'>          <span class="nl">willShowViewController:</span><span class="p">(</span><span class="n">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="n">viewController</span> <span class="nl">animated:</span><span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span><span class="n">animated</span> <span class="p">{</span>
</span><span class='line'>        <span class="k">if</span> <span class="p">(</span><span class="n">_lastViewController</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>            <span class="p">[</span><span class="n">_lastViewController</span> <span class="nl">viewWillDisappear:</span><span class="n">animated</span><span class="p">];</span>
</span><span class='line'>        <span class="p">}</span>
</span><span class='line'>
</span><span class='line'>        <span class="p">[</span><span class="n">viewController</span> <span class="nl">viewWillAppear:</span><span class="n">animated</span><span class="p">];</span>
</span><span class='line'>        <span class="n">_lastViewController</span> <span class="o">=</span> <span class="n">viewController</span><span class="p">;</span>
</span><span class='line'>    <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>If you need support for <code>viewDidAppear</code> and <code>viewDidDisappear</code> then
you&#8217;d have to implement this method as well:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='objc'><span class='line'><span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nl">navigationController:</span><span class="p">(</span><span class="n">UINavigationController</span> <span class="o">*</span><span class="p">)</span><span class="n">navigationController</span>
</span><span class='line'>       <span class="nl">didShowViewController:</span><span class="p">(</span><span class="n">UIViewController</span> <span class="o">*</span><span class="p">)</span><span class="n">viewController</span>
</span><span class='line'>                    <span class="nl">animated:</span><span class="p">(</span><span class="kt">BOOL</span><span class="p">)</span><span class="n">animated</span><span class="p">;</span>
</span></code></pre></td></tr></table></div></figure>


<p>After doing this, your view controllers should start receiving the
<code>viewWillAppear:</code> and <code>viewWillDisappear:</code> methods successfully.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Moving My Blog]]></title>
    <link href="http://benscheirman.com/2011/08/moving-my-blog/"/>
    <updated>2011-08-21T00:00:00+00:00</updated>
    <id>http://benscheirman.com/2011/08/moving-my-blog</id>
    <content type="html"><![CDATA[<p>I&#8217;ve decided to transition over to a new blog.</p>


<p>The reasons? Mostly because I&#8217;m questioning more &amp; more the need to have a dynamic blog that I need to maintain. Static HTML blog generators are very interesting and I thought I&#8217;d give one a try.</p>


<p>I&#8217;ll leave this one around for historical reasons. It gets a decent amount of traffic and has content going back to 2004.<br /></p>


<p>So without further ado I present my new blog, <a href="http://benscheirman.com">Fickle Bits</a>.<br /></p>


<p>(Note to RSS readers, your feeds will not auto-update. Subscribe to the new blog here: <a href="http://feeds.feedburner.com/ficklebits" target="_blank">Subscribe</a> )<br /></p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My Vim Journey]]></title>
    <link href="http://benscheirman.com/2011/08/my-vim-journey/"/>
    <updated>2011-08-17T23:53:00+00:00</updated>
    <id>http://benscheirman.com/2011/08/my-vim-journey</id>
    <content type="html"><![CDATA[<p>For my Rails work, I&#8217;ve largely leaned on <a href="http://macromates.org">TextMate</a>.  It&#8217;s used by many Rubyists, looks sexy,
and is easily extended.</p>

<p>I still use TextMate frequently, but I&#8217;ve been ramping up on my Vim
skills and I&#8217;ve recently come to a point where I think I&#8217;m pretty
productive in it.</p>

<p>My initial frustrations with Vim were that it was too configurable.
Talk to any Vim power-user and you&#8217;ll find a completely different set of
plugins &amp; keyboard shortcuts.  If you snag a friend&#8217;s set of Vim
configuration files (like I did) you might find yourself frustrated that
there&#8217;s too much to learn and it&#8217;s difficult to know where various
behaviors are coming from.</p>

<p>In this post, I&#8217;ll attempt to demonstrate a very sane Vim setup that
newcomers can use to get started and not be too overwhelmed.</p>

<h2>Why Vim?</h2>

<p>Before I get started with the basics of Vim, why would you use it in the
first place?</p>

<p>For me it boils down to this:  <em>I love staying on the keyboard</em>.
Vim may not make you faster (<em>in fact initially you&#8217;ll be a lot slower</em>) but it can fit your workflow better.</p>

<p>Another big differentiator of Vim is <em>Command Mode</em>.  The notion
here is that you spend more time wrangling text rather than creating it
from scratch.  That&#8217;s certainly true of my code.</p>

<p>It is important, however, that in the larger software ecosystem,
<em>typing is not the bottleneck</em>.  Don&#8217;t expect Vim to make you build
the right software faster.</p>

<p>Vim enables a keyboard-optimized workflow that <em>may</em> make you faster.
YMMV.  If you&#8217;re fast with TextMate or Emacs or don&#8217;t want to spend the
time to learn something new, then Vim may very well not be for you.</p>

<p>Lastly, Vim is ubiquitous.  It&#8217;s on every platform and
you can carry your configuration (or a very large set of it) everywhere.
People frequently put their vim configurations on Github for themselves
and others to utilize.</p>

<h2>Getting MacVim</h2>

<p>Almost all Unix-based systems (like Mac) include a terminal version of
Vim.  The version included on OS X isn&#8217;t compiled with Ruby support, so
some plugins won&#8217;t work.  In addition, it doesn&#8217;t have OS-level
integration like Copy &amp; Paste in the same buffer.</p>

<p>Most Vim users I know use MacVim, which comes pre-compiled with Ruby
support, has tabs, and more.</p>

<p>If you have <a href="http://mxcl.github.com/homebrew/">homebrew</a> installed, just
type:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>brew install  macvim</span></code></pre></td></tr></table></div></figure>


<p>If you&#8217;d rather grab a pre-built binary, then head on over <a href="https://github.com/b4winckler/macvim">here</a>.</p>

<p>You&#8217;ll also want to make sure that the <code>mvim</code> binary is in your path.</p>

<h2>Basic Vim Navigation</h2>

<p>I won&#8217;t cover everything you can do in Vim here, but here&#8217;s just enough
to get you started:</p>

<p>In Command Mode:</p>

<ul>
<li>Press <code>h</code>, <code>j</code>, <code>k</code>, <code>l</code> to move the cursor around.  It will feel weird, but you start to appreciate not
lifting your hand off of the home row to reach for the arrow keys.</li>
<li>Press <code>G</code> to go to the end of a document, <code>gg</code> to go to the top of
the document.</li>
<li>Press <code>i</code> to go to insert mode at the current position</li>
<li>Press <code>I</code> to insert at the beginning of the line</li>
<li>Press <code>a</code> to &#8220;append&#8221; content after the cursor</li>
<li>Press <code>A</code> to &#8220;append&#8221; content at the end of a line</li>
<li>Type <code>cw</code> (&#8220;change word&#8221;) to replace the current word and go into insert mode</li>
<li>Type <code>dta</code> to (&#8220;delete &#8216;til the letter a&#8221;) in a line</li>
</ul>


<p>In Insert Mode:</p>

<ul>
<li>Press <code>esc</code> to go back to command mode.</li>
</ul>


<p>Commands:</p>

<ul>
<li>In Command Mode, you can type commands by prefixing them with <code>:</code>.</li>
<li>To write the changes to the current buffer (save) type <code>:w</code> and hit
<code>enter</code>.  Often times you&#8217;ll write &amp; quit in one command, with <code>:wq</code>.</li>
</ul>


<p>Feel free to use the mouse &amp; arrow-keys while you&#8217;re getting used to everything.  It
will feel weird.</p>

<p>For more Vim-fu, definitely check out this <a href="http://peepcode.com/products/smash-into-vim-i">PeepCode
screencast</a>.</p>

<h2>Installing a Base Set of Plugins with Janus</h2>

<p>The real power of Vim is in the plugins, and fortunately Yehuda Katz &amp;
Carl Lerche have put together an opinionated and useful set of plugins
that are pre-configured and work well together.  Take a look at the plugins it includes
<a href="https://github.com/carlhuda/janus">here</a>.</p>

<p>Getting Janus installed is easy.  If you are super trust-worthy and
don&#8217;t mind running a script blindly (I don&#8217;t recommend it) you can
simply run:</p>

<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>curl https://raw.github.com/carlhuda/janus/master/bootstrap.sh -o - | sh</span></code></pre></td></tr></table></div></figure>


<p>More explicit instructions for the paranoid can be found on <a href="http://github.com/carlhuda/janus">the github
page</a>.</p>

<p>Once you have Janus installed, your Vim will be on steroids. Don&#8217;t worry
though, I&#8217;ll try to cover the most important things you&#8217;ll be using.</p>

<h2>Getting a Decent Theme installed</h2>

<p>MacVim installs a hundred nasty looking themes, but a few of them are
worth taking a look at.  Here are some that I like:</p>

<ul>
<li>molokai</li>
<li>railscasts</li>
<li>vividchalk</li>
<li>vibrantink</li>
</ul>


<p>If you want to install other themes (like this nice <a href="http://www.vim.org/scripts/script.php?script_id=2855">github</a> one) then you
simply download it &amp; copy the <code>theme.vim</code> (or whatever the theme is
called) to <code>~/.vim/colors</code>.</p>

<p>To switch between the themes that are installed, you can use the menu,
or you can type <code>:colorscheme &lt;scheme&gt;</code>.</p>

<p>To set defaults for your installation, you&#8217;d normally add commands to
<code>~/.vimrc</code> however Janus has taken that file over.  It instead reads
your settings from <code>~/.vimrc.local</code>.  In order to provide settings for
graphical Vim installations (like MacVim) there&#8217;s also a <code>~/.gvimrc</code>
file.</p>

<p>Open up that file (<code>:edit ~/.gvimrc</code>) and add the following commands:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="k">colorscheme</span> github
</span><span class='line'><span class="k">set</span> <span class="nb">guifont</span><span class="p">=</span>Menlo:h14
</span></code></pre></td></tr></table></div></figure>


<p>Feel free to tweak this to contain your favorite color scheme &amp; font.
In order to see these changes you have to &#8220;source&#8221; the file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='vim'><span class='line'><span class="p">:</span>source %
</span></code></pre></td></tr></table></div></figure>


<p>(<code>%</code> here means &#8220;current file&#8221;)</p>

<p>You should see the changes take effect immediately.</p>

<h2>Opening MacVim with a &#8220;Project&#8221;</h2>

<p>One common thing in TextMate is to <code>cd</code> into a project and then type
<code>mate .</code> which will open TextMate&#8217;s project drawer with all of the files
in that directory loaded up.</p>

<p>In MacVim, you can do the same.  Navigate to a folder with some content
(like a Rails app) and type: <code>mvim .</code></p>

<p>You should see something resembling a file navigator.  You can navigate
these with the same movement commands from above.</p>

<p>Once you&#8217;ve chosen a file, press <code>enter</code> to open it in the buffer.</p>

<p><span class='pullquote-right' data-pullquote='The leader key is a special, configurable key used to create quick shortcut combinations.'>
Janus comes with NERDTree, which has similar behavior to TextMate&#8217;s
Project Drawer.  Open up the NERDTree pane by typing <code>&lt;leader&gt;-n</code> or <code>\n</code>. By default the leader key is set to backslash.
The leader key is a special, configurable key used to create quick shortcut combinations.
</span></p>

<p>The NERDTree window can be collapsed by typing <code>&lt;leader&gt;-n</code> again.</p>

<p>You might want to instead find the file by searching for it by name.
For that, the aptly-named Command-T plugin can be hepful.</p>

<p>Command-T can be activated (by default) with <code>&lt;leader&gt;-t</code>.  Start typing
and it will auto complete the results.</p>

<h2>Scared Yet?</h2>

<p>Writing this reminds me of how hard it was to get started.  I can only
offer some encouragement that with practice, Vim does start to feel like
 you can leverage your fast typing skills to really.</p>

<p>Practice only a couple of commands at a time.  Really learn what they
are doing and then move one to the next command.  Print out a cheet
sheet.  Pair with someone else who uses Vim.</p>

<p>I hope you found this intro useful. I&#8217;ll cover some more Vim tricks as time goes on.</p>
]]></content>
  </entry>
  
</feed>
