- Initialized ExpressJS project as per this gist
project-root
├── node_modules
├── package-lock.json
| // This answer comes in 2 flavours: the "plays nice with others" version and the "hax0rz rUlez!!" version. | |
| // | |
| //-------------------------------------------------------------------------------------- | |
| // PLAYS NICE WITH OTHERS: | |
| // | |
| const arr2num = (arr) => { | |
| return arr | |
| .reverse() // work from least-to-most significant digits | |
| .reduce( |
| /** | |
| * firestore_add_field_to_all_docs_in_collection.js | |
| * | |
| * This script is assumed to live in an existing Javascript project that has its own package.json. | |
| * I store this script in <PROJECT_ROOT>/tools/cleanup/. | |
| * | |
| * To use: | |
| * 1. Import the 'firebase' and 'esm' NPM modules to your project (Run the command: `npm install firebase esm`) | |
| * 2. Edit the data for USER1 and FIREBASE_CONFIG, then adjust parameters in `main` for the call to `visitDocs`. | |
| * |
| /** | |
| * A React component: | |
| * r1. name starts with a Capital letter | |
| * r2. gets a single argument, typically referred to as "props", that is an object containing all properties passed in | |
| * r3. can use hooks (useState, useEffect, useRef, etc...) | |
| * r4. returns JSX | |
| **/ | |
| /** r1. name starts with a Capital letter */ | |
| /** r2. gets a single argument, typically named "props" */ |
| import React from "react"; | |
| import Login from "../components/Login"; | |
| import Landing from "../Pages/Landing"; | |
| function Home(props) { | |
| const [user, setUser] = useState(); | |
| return ( | |
| <div> | |
| {user ? |
| #!/bin/bash | |
| set -e # exit when any command fails | |
| function LOG() { | |
| printf 'LOG: %s %s\n' "$(date '+%b-%d %T')" "${1}" | |
| } | |
| function CLONE_GITHUB_REPO() { | |
| # | |
| # EAS_SCRT_GITHUB_CONFIG_REPOS_TOKEN is an account-level Secret stored in our Expo account's Settings |
| import React, {useContext, useState} from 'react'; | |
| import {StyleSheet, Dimensions, View, Platform} from 'react-native'; | |
| import {List, Button, Text} from 'react-native-paper'; | |
| import * as Sentry from '@sentry/react-native'; | |
| import * as Updates from 'expo-updates'; | |
| import Constants from 'expo-constants'; | |
| import { | |
| widthPercentageToDP as wPct, |
| const functions = require('firebase-functions'); | |
| const firestore = require('@google-cloud/firestore'); | |
| const client = new firestore.v1.FirestoreAdminClient(); | |
| // | |
| // Add config values with CLI command: | |
| // firebase functions:config:set my_app_name='{"fsBackupBucket":"gs://my-fs-backup-bucket"}' | |
| // | |
| const config = functions.config(); |
| import React, {createContext, useEffect, useState} from 'react'; | |
| import auth from '@react-native-firebase/auth'; // or from 'firebase/auth'; | |
| import Loading from '../components/Loading'; | |
| import {myFirestore} from '../common/firebase.js'; | |
| export const AuthContext = createContext({}); | |
| export const AuthProvider = (props) => { |
project-root
├── node_modules
├── package-lock.json
.send(). It dynamically sets Content-Type headers to match the data it sends..json() or .send().
.json() is likely less confusing.json() uses .send() under the hood so the resulting HTTP headers are the same.