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
Plug.Conn.Query.encode(%{a: [%{b: 2, c: 3}]}) == Plug.Conn.Query.encode(%{a: [%{b: 2}, %{c: 3}]}) #=> true |
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
container.register(Repository.self) { c in | |
if getEnv() == "LOCAL" { // Just an example of how a check for running environment could possibly be | |
return MockGithubRepository() | |
} else { | |
let localCache = c.resolve(LocalCache.self)! | |
let api = c.resolve(GithubAPI.self)! | |
return GithubRepository(cache: localCache, api: api) | |
} | |
} |
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
protocol Repository {} | |
class MockGithubRepository : Repository {} | |
class GithubRepository : Repository { | |
// all repository things that were already 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
class GithubAPI {} | |
class LocalCache {} | |
class Repository { | |
var api: GithubAPI | |
var cache: LocalCache | |
init(cache: LocalCache, api: GithubAPI) { | |
self.cache = cache |
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
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool | |
container = Container() | |
container.register(GithubAPI.self) { c in | |
GithubAPI() | |
} | |
container.register(LocalCache.self) { c in | |
LocalCache() | |
} |
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
// Snippet taken from https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html | |
let margins = view.layoutMarginsGuide | |
myView.leadingAnchor.constraintEqualToAnchor(margins.leadingAnchor).active = true | |
myView.trailingAnchor.constraintEqualToAnchor(margins.trailingAnchor).active = true | |
myView.heightAnchor.constraintEqualToAnchor(myView.widthAnchor, multiplier: 2.0) |
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
// Snippet taken from https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/ProgrammaticallyCreatingConstraints.html | |
let views = ["myView" : myView] | |
let formatString = "|-[myView]-|" | |
let constraints = NSLayoutConstraint.constraintsWithVisualFormat(formatString, options:.AlignAllTop , metrics: nil, views: views) | |
NSLayoutConstraint.activateConstraints(constraints) |
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
welcomeLabel.textAlignment = .Center | |
welcomeLabel.snp_makeConstraints { make in | |
make.left.equalTo(view) | |
make.right.equalTo(view) | |
make.top.equalTo(view).offset(80) | |
make.height.equalTo(50) | |
} | |
someImageView.snp_makeConstraints { make in | |
make.top.equalTo(welcomeLabel.snp_bottom).offset(40) |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(200); |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(200); |
NewerOlder