Tools and Plugins for OSX

Believe it or not I actually try to avoid plugins because they make it difficult for me to standardize my development machines, but typically some need arises and a plugin is installed…
These are most of the main tools and plugins I use for development.

Programs

  • iTerm2 – Terminal with nice split screen support and better fullscreen options
  • SublimeText – Cross platform text editor
  • SourceTree – Visual Git client
  • nvAlt – Quick note taking and searching
  • MouApp – Markdown Editor
  • join.me – Screen sharing
  • GrandPerspective – Not quite as nice as WindirStat but pretty close and the price is right.
  • Charles – Proxy app much like Fiddler but for Mac

OSX Plugins

  • Spectacle – Window manager that works great and is free.
  • Moom – Another really good Window manager for OSX that lets you do things like save and window positions to hot keys. (60/40 splits or whatever you want)
  • Oh-my-zsh – Auto completion and plugins for terminal.
  • Network Link Conditioner (Search Hardware IO Tools for Xcode) Test different network conditions by throttling bandwidth.

SublimeText 2 Plugins

  • Package Control – The simplest way to install sublime plugins
  • Tag – Great plugin for indenting and pretty printing compressed XML
  • Pretty JSON – Make JSON look pretty too
  • Indent XML – I used to use this one a lot, but recently started using Tag more.
  • Git – Sometimes its nice to be able to run quick git commands in Sublime
  • BracketHighlighter – Provides nice bracket highlighting
  • Colorpick – For quick in app color picking
  • SublimeCodeIntel – Code intelligence
  • sublime-jinja2 – Jinja2 template support

Xcode Plugins

  • XVim – Vim bindings for Xcode.
  • Mini Xcode – Minimize the main toolbar but keep access to the scheme selector

Chrome Plugins

Setting up and deploying Python Flask to Dreamhost

I have a few applications I have written that run on Flask. Every time I would go to deploy a new application I would always seem to forget one of the minor details and end up with the ugly An error occurred importing your passenger_wsgi.py

The following are the steps I use to deploy Flask to Dreamhost using Passenger. I haven’t tested it, but this should be roughly the same steps if you want to deploy directly to your domain instead of using a subdomain.

TL;DR; (Quick Setup)

  • add a new subdomain on the dreamhost web panel
  • cd myappname.domain.com
  • git clone https://github.com/icecreammatt/flask-passenger.git .
  • virtualenv .
  • . bin/activate
  • easy_install flask
  • git submodule init
  • git submodule update
  • Replace myappname.domain.com in passenger_wsgi.py with your folder path.
  • touch tmp/restart.txt
  • DONE!

Part 1 – Setup Domain

  • Go to Manage Domains after logging into the Web Panel
  • Add New Domain / Sub-Domain
    • Domain to host: I like to use subdomains a lot of testing and the different Flask apps I run, so I tend to use myappname.domain.com Obviously swap out myappname.domain.com with your own names.
    • (Optional) Check remove WWW
    • If you have more than one user account make sure to pick the correct one.
    • Web directory should fill out automatically for you
    • Passenger (Ruby/Python apps only): Check this box
  • Fully host this domain!
  • SSH into your web server and wait a minute or two for the myappname.domain.com folder to appear
  • cd into myappname.domain.com

Part 2 – Install Flask with Passenger

1. Setup a virtualenv

First we need to setup the virtual environment

$ virtualenv .
$ ls

You should now have a directory that looks something like this:

bin     
include  
lib 
public

Next activate the virtual environment by using

$ . bin/activate

The command line should now show up something like this:

(myappname.domain.com)myappname.domain.com $

2. Install Flask

$ easy_install flask

3. Setup passenger

Create a file named passenger_wsgi.py with the following:

NOTE: Make sure to hand type this, as pasting the tabbed lines from the browser can translate to spaces which will evaluate incorrectly.

import sys, os
INTERP = os.path.join(os.environ['HOME'], 'myappname.domain.com', 'bin', 'python')
if sys.executable != INTERP:
    os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())

from flask import Flask
application = Flask(__name__)

@application.route('/')
def index():
    return 'Hello Passenger'

NOTE: Don’t forget to change myappname.domain.com to match the setup you are using.

4. Start the server

Add a folder called tmp with a file named restart.txt

$ mkdir tmp
$ touch tmp/restart.txt

To restart the Flask application after making changes you need to update the restart.txt file. This can easily achieved by doing a touch tmp/restart.
(For my projects I add a post-receive hook into my git repo to touch the file for me).

The directory should now look something like this:

bin  
include  
lib  
passenger_wsgi.py
public  
tmp

5. Test

At this point you should be able to hit the server address mynameapp.domain.com from the browser and see ‘Hello passenger’

Part 3 – Deploying a real app

1. Clone sample project from github https://github.com/icecreammatt/flask-empty.git

$ pwd
/home/username/myappname.domain.com
$ git clone https://github.com/icecreammatt/flask-empty.git myappname

1. Adjust passenger_wsgi.py

Now that the basic stuff is in place a real application can be setup.

Edit passenger_wsgi.py so it now contains

import sys, os
INTERP = os.path.join(os.environ['HOME'], 'myappname.domain.com', 'bin', 'python')
if sys.executable != INTERP:
    os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())

sys.path.append('myappname')
from myappname.app import app as application

Note: Make sure if you copy this to tab os.excl… since it will copy as spaces and cause a runtime error.

Restart Flask

$ touch tmp/restart.txt

Other Resources:

I am by no means an expert at Python or Flask, I just like to code in it during my free time. Feel free to correct me on my style of code. Please post any questions or comments.

Xcode shortcuts & settings

Here are some hot keys and preferences that make life in Xcode much better.

Open quickly

quick-open Search through files, classes, and method names.
Command Shift O

Use option enter to open document in the right pane, this will also split the view if the assistant view isn’t already open. To return to single view mode use Command Enter

Split screen (Assistant Editor)

  • Switch to the assistant editor by pressing Command Option Enter
  • Return to a single screen using Command Enter
  • Open the diff view Command Option Shift Enter

Open files in active view

This settings allows for the active editor window selected to be the one changed when selecting documents from the list view or using open quickly.

General Settings

Debug Tab

Ever get annoyed when breakpoint switches away from the currently viewed file?
To stop this from happening setup a debug tab in the behavior settings.

behaviors_1behaviors-2

This last setting is a personal preference. I don’t like the console visible when I’m coding. This setting will auto hide the console after stopping the simulator.

behaviors-3

Web like navigation

Command click on method names and class names to quickly navigate to implementations.
Double click to open in a separate window. Swipe on a touch pad to go forward and back. Hold down on the back button to view the navigation history.

Press option instead of command to read inline documentation of classes and methods.

inline-documentation

Use custom key bindings to quickly switch tabs.
Select Next Tab: Control Tab
Select Previous Tab:  Control Shift Tab

tab-settings

More keys worth knowing

  • Control Command Up Switch between header and implementation
  • Command L Jump to line number
  • Command R Run simulator
  • Command B Build
  • Command Shift K Clean solution
  • Control Command Y Continue debugging
  • Command Shift Y Hide and show debug console
  • Command (1 - 7) Show different navigator tabs, hide with Command 0
    Press option to do the same with utilities on the rightDownload a cheat sheet of hotkeys here

Regain vertical space, Hide the toolbar

So now that you have instantly memorized all these hot keys you want to hide the toolbar but still be able to set the active scheme. To do this grab the plugin for the mini Xcode target selection on github

mini-xcode

Thanks to Matthew Strickland @strickland for letting me know about this plugin.

Some useful utilities for OSX

Here is a list of some useful open source tray tools I use daily.

Easy window management: Spectacle

The biggest issue I have with OSX is the way window management is handled. Simple tasks such as sizing an editor and browser so both are visible between the left and right side of the screen is cumbersome, especially with a touch pad. The simple task of maximizing a window never seems to work as expected.

Spectacle fixes these issues by providing a bunch of hot keys which you can customize to your needs. It also has a full screen that works.

SpectacleSettings

Some examples are on the homepage

System fan control: smcFanControl

This is a great app to keep your for MacBook nice and cool. With smcFanControl you can monitor temperatures, as well as customize the fan speed.

smcFanControl

Graphics monitoring: gfxCardStatus

This is a simple app that lets you monitor which graphics device is currently in use. It also lets you override which card is use such as using the integrated GPU instead of the discrete to save battery life.

gfxCardStatus

Quick image sharing: ImgurBar

The simple image sharer.
I am a big fan of Imgur and a quick way to share images with people is by using this app. Simply drag your image to the tray icon (the black dot) and it will handle the upload as well as copying a link to the image to your clipboard.

Imgur