Skip to content

Instantly share code, notes, and snippets.

View mbalex99's full-sized avatar

Maximilian Alexander mbalex99

View GitHub Profile
@mbalex99
mbalex99 / simulating-joins.swift
Created June 22, 2023 20:53
How to Do SQL-like JOINs in Ditto
class DittoManager {
let ditto: Ditto
static let shared = DittoManager()
init() {
ditto = Ditto(identity: .onlinePlayground(appID: "e23ffe6b-70d1-4246-83a8-94cbd7a79a8d", token: "f058ac2a-4576-4af1-96f2-c4788d848cf8"))
try! ditto.startSync()
}
@mbalex99
mbalex99 / gist:8802db1695f20c520ca0
Last active May 22, 2022 11:58
Alamofire and RxSwift
let rx_request = Observable<Value>.create { (observer) -> Disposable in
let requestReference = Alamofire.request(.POST, url, parameters: payload)
.responseJSON(completionHandler: { (response) in
if let value = response.result.value {
observer.onNext(value)
observer.onCompleted()
}else if let error = response.result.error {
observer.onError(error)
}
})
@mbalex99
mbalex99 / counters.ts
Last active July 8, 2019 23:37
GCounter and PNCounter
function checkSiteId(siteId: any): siteId is string {
if (typeof siteId !== "string") {
return false
}
if (siteId.trim().length === 0) {
// it's just white space
return false
}
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install vim tmux git build-essential libxml2-dev python2.7 python2.7-dev fuse libtool autoconf libusb-1.0-0-dev libfuse-dev libssl-dev libimobiledevice* usbmuxd
@mbalex99
mbalex99 / update_instructions.md
Last active March 14, 2019 22:25
update instructions with Ditto

Setting with a Dictionary

  1. given the document like so
{
    "_id": "abc123",
    "name": "Jesse",
    "username": "jchappell",
    "location": "New York",
    "score": 23
@mbalex99
mbalex99 / secondary-index.md
Last active October 16, 2018 05:29
Idea for Secondary Indexes

If we had documents in the cars collection like this:

[

    {

 "_id": "123abc",
@mbalex99
mbalex99 / sample.rs
Created May 18, 2018 01:36
WASM Bindgen Simple Class
// A struct will show up as a class on the JS side of things
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Bar {
contents: String,
}
@mbalex99
mbalex99 / Upload creation observable
Last active March 28, 2018 08:34
RxSwift with AWSS3
return create { (observer: AnyObserver<UploadSignal>) -> Disposable in
let transferUtility = AWSS3TransferUtility.defaultS3TransferUtility()
let key = String(format: "uploads/%@.png", arguments: [NSUUID().UUIDString])
let fullUrl = String(format: "https://s3.amazonaws.com/edenmessenger/%@", arguments: [key])
var uploadTask : AWSS3TransferUtilityUploadTask?
var completionUploadTask : AWSS3TransferUtilityUploadTask?
@mbalex99
mbalex99 / index.js
Created March 15, 2018 06:27
Nickname Auth
const options = {
"provider": "nickname",
"providerToken": "god",
"userInfo": {
"is_admin": true
}
};
const user = await Realm.Sync.User.registerWithProvider(`https://INSTANCE_ADDRESS`, options)
@mbalex99
mbalex99 / fakeRealmData.ts
Created November 22, 2017 00:36
Generates Fake Data for a Realm
import * as Realm from 'realm';
import * as faker from 'faker'
import * as _ from 'lodash'
// Product
export const ProductSchema: Realm.ObjectSchema = {
name: 'Product',
properties: {
productId: 'string',
name: 'string',