Skip to content

Instantly share code, notes, and snippets.

@iclems
iclems / gist:31b44bb7aba9bf7713a8
Created October 10, 2014 13:58
Firepad Copy/Paste
var MIME_TYPE = {
PLAIN: 'text/plain',
HTML: window.clipboardData ? 'Text' : 'text/html'
};
var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
function selectInput(node) {
if (ios) { // Mobile Safari apparently has a bug where select() is broken.
node.selectionStart = 0;
@iclems
iclems / Firebase Lazy-Safe Iterator
Last active June 21, 2018 09:48
This snippet enables to iterate over a Firebase reference in a non-blocking way. If you need to iterate over a large reference, a child_added query may block your Firebase as it will query the whole data before iteration. With this snippet, children are retrieved one by one, making it slower / safer.
// By Clément Wehrung
function Iterator(queueRef, processingCallback) {
this.queueRef = queueRef;
this.processingCallback = processingCallback;
this.processed = {};
this.processNext();
}
Iterator.prototype.processNext = function() {