Skip to content

Instantly share code, notes, and snippets.

View JoshuaSullivan's full-sized avatar

Joshua Sullivan JoshuaSullivan

View GitHub Profile
@JoshuaSullivan
JoshuaSullivan / pillars_order.pde
Created July 6, 2017 02:13
Control systems coming online. Order is being established…
final int PILLAR_ORDER = 6;
final float PILLAR_WIDTH = 40.0;
final float PILLAR_HEIGHT = 20.0;
final float PILLAR_SPACING = 2.0;
final float GRAVITY = -1.0;
final float ELASTICITY = -0.6;
final float MAX_HEIGHT = 500.0;
@JoshuaSullivan
JoshuaSullivan / pillars_complexity.pde
Last active July 14, 2017 00:43
As the system matures, it gains increasingly complex behavior…
final int PILLAR_ORDER = 8;
final int DIAGONALS = PILLAR_ORDER * 2 - 1;
final float PILLAR_WIDTH = 30.0;
final float PILLAR_HEIGHT = 15.0;
final float PILLAR_SPACING = 2.0;
final float GRAVITY = -1.0;
final float ELASTICITY = -0.6;
final float MAX_HEIGHT = 500.0;
@JoshuaSullivan
JoshuaSullivan / pillars_fountain.pde
Last active July 14, 2017 14:27
Some forms of motion amuse the system more than others…
final int PILLAR_ORDER = 12;
final int DIAGONALS = PILLAR_ORDER * 2 - 1;
final float PILLAR_WIDTH = 20.0;
final float PILLAR_HEIGHT = 10.0;
final float PILLAR_SPACING = 2.0;
final float GRAVITY = -1.0;
final float ELASTICITY = -0.5;
final float MAX_HEIGHT = 500.0;
@JoshuaSullivan
JoshuaSullivan / dmx.swift
Created August 31, 2017 19:25
In case you were wondering who was going to give it to you…
import Swift
struct Giver {
enum Receiver {
case ya
}
private var name: String
init(name: String) {
@JoshuaSullivan
JoshuaSullivan / arkit-quickstart.markdown
Last active October 3, 2017 17:38
A quick guide for getting up and running with ARKit.

Getting Started with ARKit

First things first: Augmented Reality is an inherently 3D activity. The ease with which you pick it up will be directly proportional to your existing experience working in 3D. This is not to say someone without 3D experience can't do AR, but it will be harder for you until you become more familiar with common 3D principles. The skill set used for creating 3D games and AR experiences are essentially the same.

If your'e a complete 3D noob, I suggest checking out some of the RayWenderlich.com tutorials on getting started with 3D game development.

Step 1: Choose your IDE

The first decision to make is whether you want to use Xcode or a 3D game framework such as Unity or Unreal to create your experience. For the purposes of this guide, I'll assume you will choose Xcode, simply because I have no personal experience with the other two options. If you're already experienced with one of them or are feeling adventurous, then I'm sure you can find AR learning resources online.

X

@JoshuaSullivan
JoshuaSullivan / CollectionViewDelegateSplitter.swift
Created December 8, 2017 20:08
These two shims allow you to split the UIScrollViewDelegate calls from the collection and table view delegate calls.
//
// CollectionViewDelegateSplitter.swift
//
// Created by Joshua Sullivan on 12/7/17.
//
import UIKit
class CollectionViewDelegateSplitter: NSObject, UICollectionViewDelegate {
/// The object which will receive collection-related delegate actions.
@JoshuaSullivan
JoshuaSullivan / natural-language-playground.swift
Last active August 2, 2018 03:22
This playground demonstrates several features of the NaturalLanguage framework that's new in iOS 12.
//: # Natural Language Framework
//: by Josh Sullivan
import Swift
import NaturalLanguage
//: Create a short string to test.
let str = "I am the very model of a modern major general! 😎"
//: And a longer one. Yay, multi-line String literals!
let longStr = """
@JoshuaSullivan
JoshuaSullivan / UIImage.Orientation+Correction.swift
Created December 3, 2018 17:32
An extension on `UIImage.Orientation` to convert it to the corresponding `CGImagePropertyOrientation` case.
extension UIImage.Orientation {
/// Get the equivalent `CGImagePropertyOrientation` enum case.
var cgOrientation: CGImagePropertyOrientation {
switch self {
case .up: return .up
case .down: return .down
case .left: return .left
case .right: return .right
case .upMirrored: return .upMirrored
case .downMirrored: return .downMirrored
@JoshuaSullivan
JoshuaSullivan / AnalyticsBackEndProtocol.swift
Created December 18, 2018 21:17
A guide to mocking objects with static methods...
protocol AnalyticsBackEnd {
static func log(_ name: String)
}
extension Analytics: AnalyticsBackEnd {}
@JoshuaSullivan
JoshuaSullivan / FormatterTest.swift
Last active April 8, 2019 18:33
Here is some example code that demonstrates the penalty incurred with creating a NSDateFormatter every time you need to format a date instead of creating it once and storing it for use when needed.
import Foundation
import QuartzCore
public func testWithMultipleInstantiation() -> CFTimeInterval {
var dateStrings: [String] = []
dateStrings.reserveCapacity(100000)
let start = CACurrentMediaTime()
for _ in 0..<100000 {
let df = NSDateFormatter()
df.dateStyle = .MediumStyle