This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [('SFO', 'HKO'), ('YYZ', 'SFO'), ('YUL', 'YYZ'), ('HKO', 'ORD')] | |
# extract nodes | |
nodes = list(set([val for s in data for val in s])) | |
# build a graph | |
graph = {} | |
for n in nodes: | |
graph[n] = [] | |
paths = [path for path in data if n in path] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Actions are method invocations from View to View Controller. | |
// Outlets are method invocations from View Controller to view. | |
// Initial Setup for ViewControllers | |
// ViewDidLoad - Called when you create the class and load from xib. Great for initial setup and one-time-only work. | |
// ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen. | |
// ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API. | |
// ViewWill/DidDisappear - Same idea as WillAppear. | |
// ViewDidUnload/ViewDidDispose - In Objective C, this is where you do your clean-up and release of stuff, but this is handled automatically so not much you really need to do here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables in Swift | |
// Every variable in Swift is declared with the keyword "var". | |
// Swift is a type-safe language. It is strongly typed. | |
// All varables is Swift are of a specific type. | |
// Swift performs type inference if the type is not declared. | |
var s = "Hello World!" // Type inferred as string | |
var i = 7 // Type inferred as integer | |
var b = false // Type inferred as boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Collections in Swift | |
// Two basic collection types in Swift, Arrays and Dictionaries. | |
// Arrays in Swift | |
// Ordered collections of items | |
// Zero based. | |
// Type safe | |
// If defined by let, it is immutable, can not be added or altered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Playground - noun: a place where people can play | |
import UIKit | |
// Flow management in Swift | |
// Parentheses are optional, curly braces are mandatory. | |
// condition must evaluate as a boolean. | |
var a = 5 | |
var b = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables in Swift | |
// Every variable in Swift is declared with the keyword "var". | |
// Swift is a type-safe language. It is strongly typed. | |
// All varables is Swift are of a specific type. | |
// Swift performs type inference if the type is not declared. | |
var s = "Hello World!" // Type inferred as string | |
var i = 7 // Type inferred as integer | |
var b = false // Type inferred as boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# installing redis server | |
mkdir /usr/local/var/log | |
mkdir /usr/local/var/db | |
brew install redis | |
# start redis server | |
redis-server /usr/local/etc/redis.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instlled Xcode, Github and Sublime Text 3 by runing their installation packages. | |
git config --global user.name "Your Full Name" | |
git config --global user.email "Your Email Address" | |
# Homebrew Installation: | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" | |
brew doctor | |
echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard HEAD~1 | |
git push origin HEAD --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nil? can be used on any Ruby object. It returns true only if the object is nil. | |
nil.nil? # => true | |
[].nil? # => false | |
{}.nil? # => false | |
"".nil? # => false | |
" ".nil? # => false | |
true.nil? # => false | |
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero. | |
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass |
NewerOlder