Skip to content

Instantly share code, notes, and snippets.

View dmcgrath's full-sized avatar

Dan McGrath dmcgrath

View GitHub Profile
// https://stackoverflow.com/a/2117523
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(
/[018]/g,
c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
@dmcgrath
dmcgrath / gist:d233237c887b474ae7277cd4633b707d
Created December 15, 2017 02:46
Cloud Firestore JavaScript
// https://stackoverflow.com/a/2117523
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(
/[018]/g,
c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
document.addEventListener('DOMContentLoaded', function() {
// // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
service cloud.firestore {
match /databases/{database}/documents {
match /notes/{doc} {
allow list: if false;
allow get: if true;
allow create: if true;
allow delete: if true;
allow update: if true;
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ComputasBrann Notes</title>
<!-- update the version number as needed -->
<script defer src="/__/firebase/4.8.0/firebase.js"></script>
<!-- include only the Firebase features as you need -->