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 / 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 / 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',
@mbalex99
mbalex99 / ticker.ts
Created August 17, 2017 20:50
Ticker File Example with Faker and Realm
import { Server } from './' // import { Server } from 'realm-object-server'
import * as faker from 'faker'
import * as Realm from 'realm'
const myNewServer = new Server({
port: 9081
})
myNewServer.start()
.then(() => {
console.log('Started! on port 9081')
@mbalex99
mbalex99 / index.ts
Last active August 16, 2017 18:36
New ROS Ticker
import { Server } from './' // import { Server } from 'realm-object-server'
import * as faker from 'faker'
import * as Realm from 'realm'
const myNewServer = new Server({
port: 9081
})
myNewServer.start()
.then(() => {
console.log('Started! on port 9081')