Skip to content

Instantly share code, notes, and snippets.

@xemasiv
xemasiv / usage.md
Created April 9, 2018 21:29
initial netcode.io usage guide

netcode.io usage

netcode.io enables a client/server architecture, handling the client/server connection handshake and encrypting the traffic between them.

server setup

  1. create a server instance:
@xemasiv
xemasiv / AssocPromise.js
Last active April 10, 2018 22:28
AssocPromise - Associative Promise, Promise All that returns Object with custom Object[key] support. Respects resolve(result) and reject(error) predictability.
class AssocPromise{
constructor () {
this._iterable = [];
}
push (iterate) {
if (Boolean(iterate._label) === false) {
return;
}
if (Boolean(iterate._fn) === false) {
return;
@xemasiv
xemasiv / asd.md
Created April 12, 2018 12:30
Increase SQLite / RockDB Size

Increase Android AsyncStorage Size in React Native The iOS AsyncStorage implementation has an unlimited amount of space by default. This is not the case on Android, the default size of AsyncStorage is 6MB. This is generally enough for a casual application however there are many cases when you may need more, like when you are using PouchDB async adapter.

To increase the size first locate the /android/app/src/main/java/MainApplication.java file in your React Native application.

We'll first add this import at the top of the MainApplication.java file

import com.facebook.react.modules.storage.ReactDatabaseSupplier;

Your imports may look something like.

@xemasiv
xemasiv / ObjectSignature.js
Last active April 12, 2018 16:12
Object Signatures
const hasha = require('hasha');
const CircularJSON = require('circular-json');
let signature = hasha(
CircularJSON.stringify(query),
{ algorithm: 'sha256' }
);
@xemasiv
xemasiv / Checker.js
Last active April 13, 2018 11:23
Checker.js - truthy, falsey & equality comparisons simplified.
class Checker{
constructor () {
this._passed = true;
}
static pairwise (list) {
// https://codereview.stackexchange.com/a/75667
let pairs = new Array((list.length * (list.length - 1)) / 2);
let pos = 0;
for (let i = 0; i < list.length; i++) {
for (let j = i + 1; j < list.length; j++) {
@xemasiv
xemasiv / BigMap.js
Created April 29, 2018 16:12 — forked from josephrocca/BigMap.js
BigMap - wrapper to get past the ~16 million key limit on JavaScript Maps
// only covers a small subset of the Map api!
// haven't debugged yet!
class BigMap {
constructor(iterable) {
if(iterable) throw new Error("haven't implemented construction with iterable yet");
this._maps = [new Map()];
this._perMapSizeLimit = 14000000;
this.size = 0;
}
@xemasiv
xemasiv / index.js
Created May 3, 2018 00:14
Notifications
var n = new Notification('Connected', { body: 'Well done mate'} );
setTimeout(() => n.close(), 3000);
Notification.permission;
Notification.requestPermission().then(console.log).catch(console.error);
// https://developer.mozilla.org/en-US/docs/Web/API/notification
@xemasiv
xemasiv / HELPERS.md
Last active May 11, 2018 16:30
Helpers
@xemasiv
xemasiv / README.md
Last active May 9, 2018 17:31
packed-map