Skip to content

Instantly share code, notes, and snippets.

@xemasiv
xemasiv / Docker.md
Last active October 31, 2017 07:26
Docker.md

(Click gist to view other files)

Interactive:

docker run -it <image> /bin/bash
# https://gist.github.com/mitchwongho/11266726

Keep it running:

@xemasiv
xemasiv / index.js
Last active December 6, 2018 03:21
Reconnecting Websockets
var socket;
const socketMessageListener = (event) => {
console.log(event.data);
};
const socketOpenListener = (event) => {
console.log('Connected');
socket.send('hello');
};
@xemasiv
xemasiv / bandwidth.js
Created December 15, 2017 12:51 — forked from mekwall/bandwidth.js
How to measure bandwidth of a server in Node.js (and some other statistics)
const net = require("net");
var server = net.createServer(function (c) {
var oldWrite = c.write;
c.write = function(d) {
if (!Buffer.isBuffer(d)) {
d = new Buffer(d);
}
oldWrite.call(this, d);
server.bytesSent += d.length;
@xemasiv
xemasiv / README.md
Created March 5, 2018 08:29 — forked from steveosoule/README.md
jQuery.getScript Cached

jquery.getScriptCached.js

jQuery's $.getScript function is a quick and easy way to include external JavaScript files into a website. However, its default implimentation will not cache the script file for the client.

The following information describes how you can itilize cached versions of $.getScript

Usage

  1. Include jquery, if it's not already.
@xemasiv
xemasiv / object.csv
Last active March 8, 2018 18:16
Sample json object.
id value
flare
flare.analytics
flare.analytics.cluster

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

@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
@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 / 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 / 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