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 / uiview_init.swift
Created Dec 6, 2014
UIView subclass initialization
View uiview_init.swift
// 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() {
// Do any additional setup after loading the view.
armstrongnate / DockerFile
Last active Aug 29, 2015
PHP and Apache on Docker
View DockerFile
FROM ubuntu:latest
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

Bash inside of ubuntu image

docker run -it -v /Users:/Users ubuntu bash

On boot

boot2docker up


Command(s) Description
o and O insert new line below and above respectively.
dd delete current line
x delete highlighted character
shift+x delete character to left
dw delete a word
de delete to end of word
/ to search, then n or N to go forward and back in results
armstrongnate / cherry-pick-migration.rb
Last active Aug 29, 2015
Cherry pick a migration
View cherry-pick-migration.rb
## One way to do it is from the rails console:
require 'db/migrate/MIGRATION_FILE_NAME.rb'
# if using def change
# if using up or down
## Another way is using a rake task
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)
armstrongnate / post.rb
Last active Aug 29, 2015
example of a many to many relationship in rails
View post.rb
class Post < ActiveRecord::Base
has_many :post_tags
has_many :tags, through: :post_tags
View java-string-formatting
// formatting numbers
// => "1.2"
String.format("%s", new DecimalFormat("#.##").format(1.2))
// => "1.20"
String.format("%.2f", 1.2)
View android-toast
Toast.makeText(getActivity().getApplicationContext(), "in onResume",
View float-compare
epsilon = .000001
x1 and x2 are equal if (fabs(x1 - x2) < epsilon)
You can’t perform that action at this time.