Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / stuns
Created April 8, 2018 21:36 — forked from zziuni/stuns
STUN server list
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net
@xemasiv
xemasiv / stuns
Created April 8, 2018 21:35 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
@xemasiv
xemasiv / index.js
Created April 5, 2018 19:53
IterablePromise - Promise.all from iterated entities without the headache.
const IterablePromise = (iterableArray, promiseExecutorFunction) => {
return Promise.all(
iterableArray.map((item, index) => {
return new Promise((resolve, reject)=>{
promiseExecutorFunction(item, index, resolve, reject);
});
})
);
};
@xemasiv
xemasiv / DataStoreReader.md
Last active April 5, 2018 18:48
DataStoreReader - Google Cloud Datastore Query Wrapper

Summary:

  • Returns a promise so it's predictable and easier to work with
  • Destructuring of entities
  • Destructuring of keys
  • Destructuring of endCursor (for Pagination support)
  • Support for SELECT, FILTER and LIMIT
  • Support for ORDER, as replaced with ASCEND and DESCEND for readability
  • Queries are chainable of course

Direct copy of pre-encoded file:

$ ffmpeg -i filename.mp4 -codec: copy -start_number 0 -hls_time 10 -hls_list_size 0 -f hls filename.m3u8