Skip to content

Instantly share code, notes, and snippets.

View jamesrochabrun's full-sized avatar
🇵🇪

James Rochabrun jamesrochabrun

🇵🇪
View GitHub Profile
{"assets":[],"layers":[{"ddd":0,"ind":0,"ty":3,"nm":"Rotator","ks":{"o":{"k":0},"r":{"k":[{"i":{"x":[0.56],"y":[1]},"o":{"x":[0.634],"y":[0]},"n":["0p56_1_0p634_0"],"t":19,"s":[0],"e":[190.7]},{"i":{"x":[0.562],"y":[1]},"o":{"x":[0.398],"y":[0]},"n":["0p562_1_0p398_0"],"t":33,"s":[190.7],"e":[176.1]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.31],"y":[0]},"n":["0p684_1_0p31_0"],"t":40.5,"s":[176.1],"e":[181.8]},{"i":{"x":[0.684],"y":[1]},"o":{"x":[0.438],"y":[0]},"n":["0p684_1_0p438_0"],"t":55,"s":[181.8],"e":[180]},{"i":{"x":[0.733],"y":[0.733]},"o":{"x":[0.385],"y":[0.385]},"n":["0p733_0p733_0p385_0p385"],"t":71,"s":[180],"e":[180]},{"i":{"x":[0.092],"y":[1]},"o":{"x":[0.406],"y":[0]},"n":["0p092_1_0p406_0"],"t":111,"s":[180],"e":[167.9]},{"i":{"x":[0.341],"y":[1]},"o":{"x":[0.6],"y":[0]},"n":["0p341_1_0p6_0"],"t":116,"s":[167.9],"e":[363]},{"i":{"x":[0.462],"y":[1]},"o":{"x":[0.167],"y":[0]},"n":["0p462_1_0p167_0"],"t":134,"s":[363],"e":[360]},{"t":141}]},"p":{"k":[200.5,149.375,0]},"a":{"k":[60,60,0]},"s":{"k
//: Playground - noun: a place where people can play
import UIKit
//swift functions are first class citizens which means that we can use them in many of the same operations which we use native types in.
//FUNCTIONS AS PROPERTIES
func sayHi(_ greeting: String) {
print(greeting)
@jamesrochabrun
jamesrochabrun / Threesumtozero.swift
Created May 3, 2017 02:06
Problem: Given a array of distinct integers, how many triple integers sum to exactly zero
//
// ComputationalGeometry.swift//
// Created by James Rochabrun on 5/2/17.
//
//
import Foundation
//types of algorhitms
//1) constant -> 1 (1)
@jamesrochabrun
jamesrochabrun / BinarySearchString.swift
Last active April 26, 2017 05:35
binary search in array of strings sorted alphabetically
var arr = ["a", "abc", "aabc", "aabbc", "aaabbbcc", "bacc", "bbcc", "bbbccc", "cb", "cbb", "cbbc", "d" , "defff", "deffz"]
func binarySearch(_ array: [String], value: String) -> String {
var firstIndex = 0
var lastIndex = array.count - 1
var wordToFind = "Not founded"
var count = 0
//1 Download the assets
https://www.yelp.com/developers/display_requirements
//2 enum to enumerate assets
enum ReviewIcon: NSNumber {
case zeroStar
case oneStar
case oneAndHalfStar
case twoStar
//: Playground - noun: a place where people can play
import UIKit
//GENERICS
//passing the reference in a method using the inout keyword
func swapInts(_ a: inout Int, _ b: inout Int) {
let tempA = a
a = b
//Given this classes
class Address {
var buildingNumber: String?
var street: String?
}
class Residence {
var numberOfRooms = 1
var address: Address?
}
class Resident {
//OPTIONAL BINDING
let weatherDictionary: [String: String] = ["currentWeather" : "22.4", "weeklyWeather" : "25.9"]
if let weekly = weatherDictionary["weeklyWeather"] {
print(weekly)
}
//prints 25.9
//DOWNSIDES OF USING IF LET AND WHY GUARD SOLVE THIS
struct Friend {
class Person {
let name: String
var apartment: Apartment?
init(name: String) {
self.name = name
}
deinit {
print("\(name) is being deinitialized, memory deallocated")
//: Playground - noun: a place where people can play
import UIKit
//fizbuzz
var oneHundred = [Int]()
for i in 1...100 {
oneHundred.append(i)
}