Skip to content

Instantly share code, notes, and snippets.

@armstrongnate
armstrongnate / DockerFile
Last active August 29, 2015 14:07
PHP and Apache on Docker
FROM ubuntu:latest
MAINTAINER Your Name <yourEmail@email.com>
RUN apt-get update
RUN apt-get -y upgrade
# Install apache, PHP, and supplimentary programs. curl and lynx-cur are for debugging the container.
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apache2 libapache2-mod-php5 php5-mysql php5-gd php-pear php-apc php5-curl curl lynx-cur
@armstrongnate
armstrongnate / uiview_init.swift
Created December 6, 2014 19:47
UIView subclass initialization
// when the view is wired up using Storyboard and a custom xib, initWithCoder is called.
class MyViewController: UIViewController {
@IBOutlet var myView: MyView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@armstrongnate
armstrongnate / csv_to_json.rb
Created December 19, 2014 17:25
convert a csv file to json
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) }
@armstrongnate
armstrongnate / navigationBarAppearance.swift
Last active August 29, 2015 14:13
custom navigation controller colors
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 / setup-tab-bar-item.swift
Last active August 29, 2015 14:18
UIViewController extension for setting tabBarItem
// 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 / fetched-results-controller.swift
Last active August 29, 2015 14:19
UITableViewController with NSFetchedResultsController boilerplate
//
// MyViewController.swift
//
// Created by Nate Armstrong on 4/15/15.
// Copyright (c) 2015 Nate Armstrong. All rights reserved.
//
import UIKit
import CoreData
@armstrongnate
armstrongnate / .docker.env
Created August 31, 2015 00:40
Docker setup for ai
DISPLAY=192.168.0.2:0 # replace `192.168.0.2` with the host machine's local ip
//
// 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
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());
@armstrongnate
armstrongnate / dequeue_default_table_view_cell.swift
Created December 11, 2015 23:22
tableView:cellForRowAtIndexPath using UITableViewCell class with preset style
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] {