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
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) }
@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 / 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 / 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 / .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
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
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());
@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 node-notes
How to install node on Ubuntu
>> git clone https://github.com/joyent/node.git
>> cd node/
>> ./configure
>> make
>> sudo make install
Install NPM
@armstrongnate
armstrongnate / angular-notes
Created Apr 18, 2013
Notes about Angular.js
View angular-notes
Raw angular app:
Make sure karma is installed
>> npm install -g karma
Clone bare angular app from angular tutorial
>> git clone git://github.com/angular/angular-phonecat.git
>> git checkout -f step-0
Run the server:
You can’t perform that action at this time.