Skip to content

Instantly share code, notes, and snippets.

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)
container.addSubview(titleView)
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
armstrongnate / dequeue_default_table_view_cell.swift
Created Dec 11, 2015
tableView:cellForRowAtIndexPath using UITableViewCell class with preset style
View dequeue_default_table_view_cell.swift
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell: UITableViewCell?
cell = tableView.dequeueReusableCellWithIdentifier(UITableViewCell.wta_reuseableIdentifier())
if cell == nil {
cell = UITableViewCell(style: .Value1, reuseIdentifier: UITableViewCell.wta_reuseableIdentifier())
}
if let result = viewModel?.results.value[indexPath.row] {
View forwardness.cpp
ai::Agent::Action * Chan::Program(const ai::Agent::Percept * percept)
{
ai::CCheckers::Action *action = new ai::CCheckers::Action;
ai::CCheckers::MoveData move;
std::string board_str = percept->GetAtom("BASIC_BOARD").GetValue();
ai::CCheckers::BasicBoard board(board_str);
int player = atoi(percept->GetAtom("PLAYER_NUMBER").GetValue().c_str());
View UIImageHelpers.swift
//
// UIImage+Blurs.swift
//
// Created by Nate Armstrong on 12/2/15.
// Copyright © 2015 Nate Armstrong. All rights reserved.
//
//
// Compression uses RBResizer: https://gist.github.com/hcatlin/180e81cd961573e3c54d
import Foundation
@armstrongnate
armstrongnate / .docker.env
Created Aug 31, 2015
Docker setup for ai
View .docker.env
DISPLAY=192.168.0.2:0 # replace `192.168.0.2` with the host machine's local ip
@armstrongnate
armstrongnate / fetched-results-controller.swift
Last active Aug 29, 2015
UITableViewController with NSFetchedResultsController boilerplate
View fetched-results-controller.swift
//
// MyViewController.swift
//
// Created by Nate Armstrong on 4/15/15.
// Copyright (c) 2015 Nate Armstrong. All rights reserved.
//
import UIKit
import CoreData
@armstrongnate
armstrongnate / setup-tab-bar-item.swift
Last active Aug 29, 2015
UIViewController extension for setting tabBarItem
View setup-tab-bar-item.swift
// usage
class MyViewController: UIViewController {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupTabBarItem("entries")
}
}
// where "entries" is the name of the image.
// should have 2 images named tabbar-entries and tabbar-entries-selected
@armstrongnate
armstrongnate / navigationBarAppearance.swift
Last active Aug 29, 2015
custom navigation controller colors
View navigationBarAppearance.swift
let navigationBarAppearance = UINavigationBar.appearance()
navigationBarAppearance.barTintColor = UIColor(red:170.0/255.0, green:65.0/255.0, blue:65.0/255.0, alpha:1.0)
navigationBarAppearance.tintColor = UIColor.whiteColor()
navigationBarAppearance.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
@armstrongnate
armstrongnate / csv_to_json.rb
Created Dec 19, 2014
convert a csv file to json
View csv_to_json.rb
require 'csv'
require 'json'
date = 5
file_name = "weather-2014-12-#{date}"
body = File.open("/path/to/file/#{file_name}.csv", 'rb').read
csv = CSV.new(body, :headers => true, :header_converters => :symbol, :converters => :all)
weather = csv.to_a.map {|row| row.to_hash }
File.open("/path/to/file/#{file_name}.json", 'w') { |f| f.write(weather.to_json) }
You can’t perform that action at this time.