Skip to content

Instantly share code, notes, and snippets.

Nate Armstrong armstrongnate

Block or report user

Report or block armstrongnate

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
armstrongnate / basic-auth.swift
Created Jul 20, 2014
HTTP Basic Authentication using NSURLSession in swift
View basic-auth.swift
import Foundation
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let userPasswordString = ""
let userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
let base64EncodedCredential = userPasswordData!.base64EncodedStringWithOptions(nil)
let authString = "Basic \(base64EncodedCredential)"
config.HTTPAdditionalHeaders = ["Authorization" : authString]
let session = NSURLSession(configuration: config)
View helm-conflict.swift
<<<<<<< HEAD
if let titleView: UIView = titleViewFromNavBarImagePath(navBarImagePath: navBarImagePath) {
titleView.contentMode = .scaleAspectFit
let container = UIView(frame: CGRect(x: 0, y: 0, width: 32, height: 32))
titleView.frame = CGRect(x: 0, y: 0, width: 32, height: 32)
self.navigationItem.titleView = container
else {
self.navigationItem.titleView = nil
View Folder+NetworkTests.swift
func testDeleteFolder() {
attempt {
let session = Session.nas
var response: JSONObject?
stub(session, "delete-folder") { expectation in
try! Folder.deleteFolder(session, folderID: "10396915")
.startWithCompletedExpectation(expectation) { value in
response = value
armstrongnate / ruby on mavericks
Created Nov 8, 2013
instal ruby on mavericks with rbenv
View ruby on mavericks
# XCode 5 hides these away:
export C_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include"
export CPLUS_INCLUDE_PATH="$(xcrun --show-sdk-path)/usr/include"
export LIBRARY_PATH="$(xcrun --show-sdk-path)/usr/lib:$(xcrun --show-sdk-path)/usr/lib/system:$LIBRARY_PATH"
and then you can do rbenv install
View add_index
class AddIndexOnCompanyIdInConcernsAndDepartmentsAndUsers < ActiveRecord::Migration
def change
add_index :departments, :company_id
add_index :concerns, :company_id
add_index :users, :company_id
armstrongnate / mysql start
Created Jun 26, 2013
start mysql after reboot
View mysql start
mysql.server start
armstrongnate / awakeFromNib
Created Jun 4, 2013
how to call awakeFromNib method inside View Controller (method that gets called before viewDidLoad, mostly used for geometry changes)
View awakeFromNib
// the following class inherits from UIViewController
@implementation MyCustomViewController
- (void)setup
// initialization that can't wait until viewDidLoad
- (void)awakeFromNib
armstrongnate / nsObjectInit
Last active Dec 18, 2015
base init method of NSObject
View nsObjectInit
@implementation MyCustomClass
- (id)init
self = [super init];
if (self) {
// custom initializations
// use underscore assignment (_date = [NSDate date]) instead of setters and getters
armstrongnate / rbenv 187 mountain lion
Created May 24, 2013
Install ruby 1.8.7 using rbenv on mountain lion.
View rbenv 187 mountain lion
Ultimately, this line did the trick:
$ CONFIGURE_OPTS="--without-tk" rbenv install 1.8.7-p370
Additional info:
armstrongnate / json request objective c
Last active Dec 17, 2015
JSON HTTP request in objective-c
View json request objective c
NSURL *wiresUrl = [NSURL URLWithString:@""];
NSData *jsonData = [NSData dataWithContentsOfURL:wiresUrl];
NSError *error = nil;
NSDictionary *dataDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
You can’t perform that action at this time.