Skip to content

Instantly share code, notes, and snippets.

View maltebucksch's full-sized avatar

Malte Bucksch maltebucksch

View GitHub Profile
@maltebucksch
maltebucksch / introrx.md
Created October 8, 2016 09:07 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@maltebucksch
maltebucksch / espressoexample.java
Last active March 29, 2018 09:42
Espresso Example
@Test
public void testAddNote() {
// press “add note” button
onView(withId(R.id.addNote)).perform(click());
// type “Espresso rules” as the note content
onView(withId(R.id.noteContent)).perform(typeText("Espresso rules"));
// press “ok/save” button
onView(withId(R.id.ok)).perform(click());
// check if note-list contains note with the text “Espresso rules"
onView(withText("Espresso rules")).check(matches(isDisplayed()));
@maltebucksch
maltebucksch / DeveloperTeamTest.swift
Created May 22, 2018 08:29
Evaluating a great developer team
func test_TeamIsAwesome() {
let quickBirdTeamMembers = fetchTeamMembers()
let awesomeTeamMembers = quickBirdTeamMembers.filter { teamMember in
teamMember.isPassionate &&
teamMember.isFriendly &&
teamMember.isConstantlyImproving
}
XCTAssertEqual(quickBirdTeamMembers.count, awesomeTeamMembers.count)
@maltebucksch
maltebucksch / DeveloperTeamTest.kt
Last active August 19, 2022 18:32
Evaluating a great developer team
fun testTeamIsAwesome() {
val quickBirdTeamMembers = fetchTeamMembers()
val awesomeTeamMembers = quickBirdTeamMembers.filter { teamMember ->
teamMember.isPassionate &&
teamMember.isFriendly &&
teamMember.isConstantlyImproving
}
assertEquals(quickBirdTeamMembers.size, awesomeTeamMembers.size)
@maltebucksch
maltebucksch / User.swift
Last active June 26, 2018 07:56
Sync-service: User-model
class User: Object {
@objc dynamic var id: Int = 0
@objc dynamic var username: String = ""
@objc dynamic var updatedDate: Date = Date()
override static func primaryKey() -> String? {
return "id"
}
}
@maltebucksch
maltebucksch / Uploadable.swift
Created June 26, 2018 07:59
Realm Sync Service: Uploadable
protocol Uploadable: Decodable {
var resourceURL: URL { get }
}
@maltebucksch
maltebucksch / User-full.swift
Created June 26, 2018 08:00
Realm Sync Service: User-Full
class User: Object, Uploadable {
@objc dynamic var id: Int = 0
@objc dynamic var username: String = ""
@objc dynamic var updatedDate: Date = Date()
override static func primaryKey() -> String? {
return "id"
}
var resourceURL: URL {
@maltebucksch
maltebucksch / Uploadable+sync.swift
Created June 26, 2018 08:01
Realm Sync Service: Uploadable-Extension
extension Uploadable where Self: Object {
func getId() -> String {
guard let primaryKey = type(of: self).primaryKey() else {
fatalError("Object can't be managed without a primary key")
}
guard let id = self.value(forKey: primaryKey) else {
fatalError("Objects primary key isn't set")
}
@maltebucksch
maltebucksch / Uploadable+changes.swift
Created June 26, 2018 08:02
Realm Sync Service: Detecting changes
typealias Syncable = Object & Uploadable
struct Update {
let insertions: [Syncable]
let modifications: [Syncable]
let deletedIds: [String]
let type: Syncable.Type
}
extension Uploadable where Self: Object {
@maltebucksch
maltebucksch / AppDelegate-line.swift
Created June 26, 2018 08:03
Realm Sync Service: Sync Service Creation
syncService = SyncService(modelTypes: [User.self])