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
describe(`Quickbird Studios Team`, function() { | |
it(`should be an awesome team`, function() { | |
const quickBirdTeamMembers = fetchTeamMembers(); | |
const awesomeTeamMembers = quickBirdTeamMembers.filter(teamMember => | |
teamMember.isPassionate && | |
teamMember.isFriendly && | |
teamMember.isConstantlyImproving | |
); | |
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
// let’s say we have 2 variables | |
b = 1, c = 1 | |
// and a third which is the sum of both | |
a := b + c | |
print(a) // output wil be “2” (so far, so good) | |
// now let’s change the value of “c” | |
c = 2 | |
print(a) |
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
private int count = 0; | |
// returns something different every time you call the function (not functional!) | |
private int getCount(){ | |
count++; | |
return count; | |
} |
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
keyboardInput.filter(input -> isEmailValid(input)) | |
.map(email -> getEmailPrefix(email)) | |
.subscribe(emailPrefix -> | |
System.out.println("New User: " + emailPrefix) | |
); |
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
interface PatternDetector { | |
fun findPatterns(data: List<Weight>): List<Pattern> | |
} |
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
private static func performRequest(method: String, url: URL, data: Data? = nil) { | |
if let data = data { | |
let json = String(decoding: data, as: UTF8.self) | |
print("\(method): \(url.path)\n\(json)") | |
} else { | |
print("\(method): \(url.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
private static func upload(_ object: Syncable, isUpdated: Bool) { | |
let url: URL | |
let httpMethod: String | |
if isUpdated { | |
url = object.resourceURL.appendingPathComponent("/\(object.getId())") | |
httpMethod = "PUT" | |
} else { | |
url = object.resourceURL | |
httpMethod = "POST" |
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
private static func handleUpdate(_ update: Update) { | |
update.insertions.forEach { upload($0, isUpdated: false) } | |
update.modifications.forEach { upload($0, isUpdated: true) } | |
update.deletions.forEach { deleteObject(withId: $0, ofType: update.type) } | |
} |
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 SyncService { | |
private let realm: Realm | |
private let tokens: [NotificationToken] | |
init(modelTypes: [Syncable.Type], realm: Realm = try! Realm()) { | |
self.realm = realm | |
tokens = modelTypes.map { modelType in | |
modelType.registerNotificationObserver(for: realm, callback: SyncService.handleUpdate) |
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
var syncService: SyncService! | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
syncService = SyncService(modelTypes: [User.self]) | |
return true | |
} |
NewerOlder