This file contains hidden or 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 Db | |
| { | |
| public function batchInsert($table, array $rows, array $columns = array()) | |
| { | |
| // Is array empty? Nothing to insert! | |
| if (empty($rows)) { | |
| return true; | |
| } |
This file contains hidden or 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
| npm install -g npm-check-updates | |
| ncu -u | |
| npm update | |
| npm install |
This file contains hidden or 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
| If you ever get into out-of-sync trouble, clear your working tree on your fork (git add && git commit && git push) and | |
| run the following: | |
| git checkout master | |
| // git fetch upstream (add this for a slightly safer solution) | |
| git reset --hard upstream/master | |
| git push --force |
This file contains hidden or 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
| React Firebase Check List (Revision 1.0): | |
| Dependencies: | |
| i) Node and NPM | |
| ii) firebase-tools | |
| iii) VSCode | |
| This checklist is suitable for you if: | |
| i) You use Windows operating system. | |
| ii) You use ReactJS as your development library and Firebase as your BaaS. |
This file contains hidden or 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
| // Allow read/write access on all documents to any user signed in to the application | |
| service cloud.firestore { | |
| match /databases/{database}/documents { | |
| match /{document=**} { | |
| allow read, write: if request.auth != null; | |
| } | |
| } | |
| } |
This file contains hidden or 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
| db.collection("users").get().then((querySnapshot) => { | |
| querySnapshot.forEach((doc) => { | |
| console.log(`${doc.id} => ${doc.data()}`); | |
| }); | |
| }); |
This file contains hidden or 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
| // Add a first document with a generated ID. | |
| db.collection("users").add({ | |
| first: "Ada", | |
| last: "Lovelace", | |
| born: 1815 | |
| }) | |
| .then((docRef) => { | |
| console.log("Document written with ID: ", docRef.id); | |
| }) | |
| .catch((error) => { |
This file contains hidden or 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
| // Asynchronous Function Callback | |
| function loadAsset(url, cb) { | |
| let xhr = new XMLHttpRequest(); | |
| xhr.open("GET", url); | |
| xhr.addEventListener("readystatechange", () => { | |
| if (xhr.readyState === 4 && xhr.status === 200) { | |
| cb(undefined, JSON.parse(xhr.responseText)); | |
| } else if (xhr.readyState === 4) { |
This file contains hidden or 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
| fetch("https://jsonplaceholder.typicode.com/todos/") | |
| .then((response) => response.json()) | |
| .then(data => { | |
| console.log(data) | |
| }) | |
| .catch((err) => { | |
| console.log('rejected', err) | |
| }) |
This file contains hidden or 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
| function getTodos(resource) { | |
| return new Promise((resolve, reject) => { | |
| const request = new XMLHttpRequest(); | |
| request.addEventListener("readystatechange", () => { | |
| if (request.readyState === 4 && request.status === 200) { | |
| resolve(request.responseText); | |
| } else if (request.readyState === 4) { | |
| reject("Error getting resource"); | |
| } |
NewerOlder