Skip to content

Instantly share code, notes, and snippets.

Avatar

Maximilian Alexander mbalex99

View GitHub Profile
@mbalex99
mbalex99 / counters.ts
Last active Jul 8, 2019
GCounter and PNCounter
View counters.ts
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
}
View raspbian-usbmuxd.sh
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 Mar 14, 2019
update instructions with Ditto
View update_instructions.md

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 Oct 16, 2018
Idea for Secondary Indexes
View secondary-index.md

If we had documents in the cars collection like this:

[

    {

 "_id": "123abc",
@mbalex99
mbalex99 / sample.rs
Created May 18, 2018
WASM Bindgen Simple Class
View sample.rs
// 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 Mar 15, 2018
Nickname Auth
View index.js
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 Nov 22, 2017
Generates Fake Data for a Realm
View fakeRealmData.ts
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 Aug 17, 2017
Ticker File Example with Faker and Realm
View ticker.ts
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 Aug 16, 2017
New ROS Ticker
View index.ts
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 / MyDoctorsViewController.swift
Last active Jul 28, 2017
Observing and Writing to Real-time Offline First Realm
View MyDoctorsViewController.swift
import UIKit
import RealmSwift
class Doctor: Object {
dynamic var _id: String = ""
dynamic var name: String = ""
dynamic var address: String = ""
dynamic var updatedOn: NSDate = NSDate()
}