Skip to content

Instantly share code, notes, and snippets.

View nathanborror's full-sized avatar

Nathan Borror nathanborror

View GitHub Profile

Auto-Layout

Very simple convenience class to make working with Auto-Layout easier.

class Layout {

    let views: [String:UIView]
    let superview: UIView

Remote Virtual Interface

Taken directly from: https://developer.apple.com/library/mac/qa/qa1176/_index.html#//apple_ref/doc/uid/DTS10001707-CH1-SECRVI

iOS 5 added a remote virtual interface (RVI) facility that lets you use OS X packet trace programs to capture traces from an iOS device. The basic strategy is:

  1. Connect your iOS device to your Mac via USB.
  2. Set up an RVI for that device. This creates a virtual network interface on your Mac that represents the iOS device's networking stack.
  3. Run your OS X packet trace program, and point it at the RVI created in the previous step.
  4. To set up an RVI, you should run the rvictl tool as shown below.
@nathanborror
nathanborror / ViewController.swift
Last active August 29, 2015 14:05
Programatic example of UISearchDisplayController
//
// ViewController.swift
// Example
//
// Created by Nathan Borror on 8/28/14.
// Copyright (c) 2014 Nathan Borror. All rights reserved.
//
import UIKit
class MasterViewController: UIViewController, UINavigationControllerDelegate {
init() {
super.init(nibName: nil, bundle: nil)
}
}
extension MasterViewController: UITableViewDataSource {
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
Host e
HostName 54.208.83.100
User ubuntu
IdentityFile ~/.ssh/your-key-pair.pem
description "start and stop the go program 'my-project'"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
env USER='ubuntu'
env APP_DIR='/home/ubuntu/go/src/github.com/your-username/your-project-name/'
env APP_EXEC='your-project-name'
exec start-stop-daemon —start —chuid ${USER} —chdir ${APP_DIR} —exec ${APP_DIR}${APP_EXEC}

Keybase proof

I hereby claim:

  • I am nathanborror on github.
  • I am nathanborror (https://keybase.io/nathanborror) on keybase.
  • I have a public key whose fingerprint is 5D26 8211 E160 5ED3 F5E2 D49E 9533 D273 8B6C BC97

To claim this, I am signing this object:

@nathanborror
nathanborror / gist:9338630
Created March 4, 2014 01:39
constraintsWithVisualFormats
// NSArray *formats = @[
// @"H:|-[textView]-|",
// @"H:|-[moreButton]-|",
// @"V:|-[textView]-[moreButton]-|",
// ];
// [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormats:formats options:0 metrics:nil views:views]];
@implementation NSLayoutConstraint (Common)
@nathanborror
nathanborror / gist:3470564
Created August 25, 2012 20:21
Readernaut API

Readernaut API

I'm going to be deprecating the current Readernaut API in favor of a newer more built-out version. People using the current version have two weeks to switch over to the new API. Currently you can find your API_KEY by viewing source on any page and searching for "api_key" in the output (this will get better later). Here are some example endpoints:

Notes

  • Old: /services/api/USERNAME/notes/
  • New: /api/v1/notes/note/?username=YOUR_USERNAME&api_key=YOUR_API_KEY&user__username=USERNAME

Books

@nathanborror
nathanborror / gist:2884560
Created June 6, 2012 20:29
Mediator Pattern
define([], function(obj) {
var channels = {};
if (!obj) obj = {};
obj.subscribe = function(channel, subscription) {
if (!channels[channel]) channels[channel] = [];
channels[channel].push(subscription);
return channels[channel].length -1;
};