This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST https://firestore.googleapis.com/v1beta1/projects/firestore-fun/databases/(default)/documents:commit?key={YOUR_API_KEY} | |
{ | |
"writes": [ | |
{ | |
"update": { | |
"name": "projects/firestore-fun/databases/(default)/documents/foo/bar", | |
"fields": { | |
"some-field": { | |
"stringValue": "some-value" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeMirror.setOption('onDragEvent', function(cm, e) { | |
// Move the cursor as they drag. | |
var pos = codeMirror.coordsChar({left: e.x, top: e.y }); | |
codeMirror.setCursor(pos); | |
codeMirror.focus(); | |
var isImageDrop = e.type == 'drop' && e.dataTransfer.files && e.dataTransfer.files.length > 0 && e.dataTransfer.files[0].type && e.dataTransfer.files[0].type.indexOf('image/') > -1; | |
if (!isImageDrop) return; | |
event.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var presenceRef = new Firebase('https://mike.firebaseio.com/users/michael/presence'); | |
presenceRef.root().child('.info/connected').on('value', function(s) { | |
if (s.val() === true) { | |
// we're connected. Set up presence with a per-session presence bit. | |
var ref = presenceRef.push(); | |
ref.onDisconnect().remove(); | |
ref.set(true); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'); | |
var fs = require('fs'); | |
var Firepad = {}; | |
Firepad.load = function(ref, callback) { | |
jsdom.env('<head></head><body><div id="firepad"></div></body>', function (errors, window) { | |
var document = document || window.document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firepad.insertEntity('img', { | |
'src' : 'http://cdn.dashburst.com/wp-content/uploads/2013/01/Grumpy-Cat.jpg', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.firepad { | |
height: auto; | |
} | |
.firepad-toolbar { | |
position: relative; | |
margin-top: 20px; | |
margin-left: 10px; | |
top: auto; | |
left: auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firepad.registerEntity('img', { | |
render: function(info, handle) { | |
var attrs = ['src', 'alt', 'width', 'height', 'style', 'class']; | |
var html = '<img '; | |
for(var i = 0; i < attrs.length; i++) { | |
var attr = attrs[i]; | |
if (attr in info) { | |
html += ' ' + attr + '="' + info[attr] + '"'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeMirror.setOption('onDragEvent', function(cm, e) { | |
// Move the cursor as they drag. | |
var pos = codeMirror.coordsChar({left: e.x, top: e.y }); | |
codeMirror.setCursor(pos); | |
codeMirror.focus(); | |
var isImageDrop = e.type == 'drop' && e.dataTransfer.files && e.dataTransfer.files.length > 0 && e.dataTransfer.files[0].type && e.dataTransfer.files[0].type.indexOf('image/') > -1; | |
if (!isImageDrop) return; | |
event.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set autoindent ignorecase noerrorbells ruler hlsearch sw=4 sts=4 expandtab | |
set textwidth=79 nowrapscan formatoptions-=t incsearch tabstop=4 | |
set scrolloff=2 norestorescreen history=100 shortmess=ao nobackup | |
set matchtime=1 showmatch smartcase wildmenu wildmode=longest:full | |
syntax on | |
map Q gq | |
map Y y$ | |
behave xterm |
NewerOlder