Skip to content

Instantly share code, notes, and snippets.

View mbalex99's full-sized avatar

Maximilian Alexander mbalex99

View GitHub Profile
@mbalex99
mbalex99 / MyDoctorsViewController.swift
Last active July 28, 2017 20:22
Observing and Writing to Real-time Offline First Realm
import UIKit
import RealmSwift
class Doctor: Object {
dynamic var _id: String = ""
dynamic var name: String = ""
dynamic var address: String = ""
dynamic var updatedOn: NSDate = NSDate()
}
@mbalex99
mbalex99 / rcli.md
Last active April 17, 2017 23:04
Realm CLI Notes

Basic Setup

  • To install the cli, you will do npm install -g realm-cli
  • To aim the cli at a host you can do it either of 3 ways
    1. realm-cli -h "localhost:9080" ..args
    2. realm-cli -host "localhost:9080"" ...args
    3. To set a host for future commands simply call realm-cli use "localhost:9080"
    4. To clear a host realm-cli use "" or realm-cli use

Controlling a Service

@mbalex99
mbalex99 / plan.md
Last active April 13, 2017 21:28
Super Bloom
  • Ileana Betancourt
  • Max Alexander, 415 930 0285
  • Adam Butler, 508 320 9898
  • Adam Fish
@mbalex99
mbalex99 / node-realm-interview-questions.md
Last active April 12, 2017 19:49
Realm Node Interview Questions

Coding Questions

  1. How would you explicity notify the node run loop to execute some code. For example, we have C++ calling JavaScript. C++ code is not aware of the JavaScript/Node event loop
  2. Show me your ways of getting rid of callback hell.
  3. How would you handle uncaught exceptions in node?
  4. This takes a long time in Chrome but not in Node why?
console.time("cycle")
for(var i = 0; i < 5000000; i++) {
  //nothing
}
@mbalex99
mbalex99 / piechartdata.swift
Last active November 15, 2016 06:45
Swift PieChartData
let entry1 = PieChartDataEntry(value: 0.75, label: "Something1")
let entry2 = PieChartDataEntry(value: 0.25, label: "Something2")
let dataSet = PieChartDataSet(values: [entry1, entry2], label: nil)
dataSet.colors = [UIColor.red, UIColor.blue] // in order of the entries by index
pieChartView.data = PieChartData(dataSet: dataSet)

Boats

  • Boat1: 26.971038, -129.023438
  • Boat2: 30.363396, -66.796875
  • Boat3: 40.905210, -130.429688

Towers

  • Tower1: 45.019185, -112.500000
  • Tower2: 37.918201, -108.281250
  • Tower3: 30.968189, 92.109375
class Annotation {
interface AnnotationLatLngChange {
onChange(LatLng latLng);
}
AnnotationLatLngChange changeHandler;
LatLng getLatLng();
void setLatLng();
}
@mbalex99
mbalex99 / login.swift
Created May 5, 2016 16:38
RxSwift Login with Firebase
logInButton.rx_tap
.flatMap { [unowned self] () -> Observable<FAuthData> in
firebaseRef.rx_authUser(self.emailTextField.text!, password: self.passwordTextField.text!)
}
.catchError({ (error) -> Observable<String?> in
return Observable.just(error.someErrorMessage) // figure out what you want to say.
})
.observeOn(MainScheduler.instance) //not needed since Firebase will always by default deliver on the MainThread.
.subscribeNext { [unowned self] (errorMessage: String?) in
if let errorMessage = errorMessage else { // SHOW ALERT }
@mbalex99
mbalex99 / handledisplayview.swift
Created March 13, 2016 00:31
HandleDisplayView for Eden
import UIKit
import RxSwift
import Cartography
class HandleDisplayView: UIView {
private var disposeBag = DisposeBag()
@mbalex99
mbalex99 / rxfirebase-typescript-angular.ts
Last active December 29, 2015 14:23
class for RxFirebase with Angular2 and TypeScrpt
import {Observable, Subscriber} from 'rxjs/Rx'
export enum EventType {
CHILD_ADDED, CHILD_REMOVED, CHILD_CHANGED, CHILD_MOVED, VALUE
}
export interface RxFirebaseResponse {
snapshot: FirebaseDataSnapshot
siblingKey: string
}