- Read records from database.
- For each record issue HTTP GET for a webservice and recieve a response.
- Store resonses to corresponding document back.
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
/*************************************************** | |
* Simple and elegant, no code complexity | |
* Disadvantages: Requires warming all data into server memory (could take a long time for MBs of data or millions of records) | |
* (This disadvantage should go away as we add optimizations to the core product) | |
***************************************************/ | |
var fb = firebase.database.ref(); | |
/** | |
* @param {string} emailAddress |
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
<?php | |
/** | |
* Class TorDetector | |
* | |
* Helps to detect if visitors are using a Tor browser to surf the website. | |
* | |
* Thanks to https://trac.torproject.org/projects/tor/wiki/doc/TorDNSExitList | |
*/ | |
class TorDetector |
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
let hasBlobConstructor = typeof(Blob) !== 'undefined' && (function () { | |
try { | |
return Boolean(new Blob()); | |
} catch (e) { | |
return false; | |
} | |
}()); | |
let hasArrayBufferViewSupport = hasBlobConstructor && typeof(Uint8Array) !== 'undefined' && (function () { | |
try { |
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
// When the EditText is touched, disable touches on it's ScrollView's parents. | |
// Once the user lifts up their finger, enable touches on on the ScrollView's parents once again. | |
@OnTouch(R.id.edit_text) | |
boolean handleNoteFieldTouch(View v, MotionEvent event) { | |
v.getParent().getParent().requestDisallowInterceptTouchEvent(true); | |
switch (event.getAction() & MotionEvent.ACTION_MASK){ | |
case MotionEvent.ACTION_UP: | |
v.getParent().getParent().requestDisallowInterceptTouchEvent(false); | |
break; |
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
public class FirebaseUserIdTokenInterceptor implements Interceptor { | |
// Custom header for passing ID token in request. | |
private static final String X_FIREBASE_ID_TOKEN = "YOUR-CUSTOM-HEADER"; | |
@Override | |
public Response intercept(Chain chain) throws IOException { | |
Request request = chain.request(); | |
try { |
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
#!/bin/bash | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
EXPORT_FILE=$DIR'/memo-save.txt' | |
READ_ONLY=1 | |
for param in "$@" | |
do | |
if [ $param = "edit" ] | |
then | |
READ_ONLY=0 |
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
service cloud.firestore { | |
match /databases/{database}/documents { | |
// START - Usage example | |
match /people/{document=**} { | |
function propertiesValid() { | |
return request.resource.data.keys().hasAll(['name', 'birthdate', 'yearsOfExperience']) | |
&& request.resource.data.size() == 3 | |
&& isString('name') && minlength('name', 3) && maxlength('name', 255) |
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
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
OlderNewer