Skip to content

Instantly share code, notes, and snippets.

View gregfenton's full-sized avatar

Greg Fenton gregfenton

View GitHub Profile
@gregfenton
gregfenton / Location Selector
Last active May 2, 2020 20:46 — forked from hanuz06/Location Selector
Location Selector
import React, { useState, useEffect } from "react";
import {
StyleSheet,
Text,
View,
ActivityIndicator,
Alert,
Button,
} from "react-native";
import * as Location from "expo-location";
@gregfenton
gregfenton / useVehicleList.js
Created June 8, 2020 00:02
a custom hook for "paging" queries to Firestore
import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
export const FIRESTORE_META_ID = "__META_ID__";
/**
* A custom hook to query the "vehicles" top collection of a Firestore database.
*
* @param {Firestore} firestore - instance of firestore, such as you get in props when a parent component is wrapped in `withFirestore()`
* @param {number} pageNum - the current page number to fetch; first page is 0, second page is 1, etc...
@gregfenton
gregfenton / cleanup_firestore.js
Last active September 10, 2023 02:18
Deletes all records from a Firestore collection that match some criteria -- command-line JavaScript/node
/**
* cleanup_firestore.js
*
* This code is a "node script" used to delete all documents from a Firestore
* collection that are older than a given date. This script can run against
* "the cloud" or the emulator.
*
* The jump point for the script is this line in main():
*
* await deleteDocs('orders', 'closedDate', '<', new Date('2021/08/31'))
@gregfenton
gregfenton / load_json_to_firestore.js
Last active September 8, 2024 17:42
Loads JSON data into a Firestore database (cloud or local emulator) -- command-line JavaScript/node
/**
* load_json_to_firstore.js
*
* This code is a "node script" used to load data into your Firestore database, either in "the cloud" or the emulator.
*
* The script is a "client app", so it logs in with Firebase Auth using email/password from the variable USER1.
*
* The USER1 user ([email protected]) must exist in your Firebase project and have write access
* to the collection(s) you are populating. You can create that account via Firebase Console >> Authentication.
*
@gregfenton
gregfenton / fetch-user-records-from-google-sheets.js
Last active December 7, 2022 23:00
Downloads data from a Google Sheets worksheet and stores in a local JSON file -- command-line JavaScript/node
/**
* A script that:
* 1. loads Google Sheets API keys and spreadsheet IDs (see GOOGLE_API_KEY)
* 2. connects to the identifed Google Sheet
* 3. grabs the data from a named Worksheet (see SHEET_TO_GET)
* 4. iterates over each row (see processUserRows())
* 5. puts them into a JSON structure
* 6. and writes that out to a file (see FILE_NAME)
*
* To run this script, I have this in my package.json:
@gregfenton
gregfenton / android_logcat.log
Last active February 26, 2021 17:27
REACT-NATIVE: output from `logcat` starting just as the UI is clicked to display the component that includes [MapView](https://docs.expo.io/versions/latest/sdk/map-view/) from react-native-maps
09-26 13:53:23.229 1397 5471 W audio_hw_generic: Not supplying enough data to HAL, expected position 2427928 , only wrote 2427853
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: Error while updating prop left
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: java.lang.reflect.InvocationTargetException
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: at java.lang.reflect.Method.invoke(Native Method)
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: at abi38_0_0.com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateShadowNodeProp(ViewManagersPropertyCache.java:7)
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: at abi38_0_0.com.facebook.react.uimanager.ViewManagerPropertyUpdater$FallbackShadowNodeSetter.setProperty(ViewManagerPropertyUpdater.java:2)
09-26 13:53:23.236 6517 6654 E unknown:ViewManager: at abi38_0_0.com.facebook.react.uimanager.ViewManagerPropertyUpdater.updateProps(ViewManagerPropertyUpdater.java:14)
09-26 13:53:23.236 6517 6654 E unknown:ViewMa
@gregfenton
gregfenton / EXPO_BARE_WORKFLOW.md
Last active February 26, 2021 17:27
EXPO: a description of ejecting an app from Expo Managed Workflow to run & debug it in Android Studio
@gregfenton
gregfenton / .versionrc.js
Last active February 18, 2023 22:43
EXPO: configuration of standard-version-expo for a code base that has multiple configuration files
/* What?
* A configuration for standard-version-expo that updates multiple config files
* by dynamically identifying them from a sub-directory when you bump the
* version using the `standard-version` tool
*
* How?
* Modelled from the post by @bycedric: https://dev.to/bycedric/simplify-expo-releases-with-standard-version-2f4o
* Follow the setup instructions listed at the URL above or at https://github.com/expo-community/standard-version-expo
*
* Why?
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "xxx";
const char* password = "xxxxxxx";
const char* url = "https://api.angelcam.com/v1/events/";
const char* fingerprint = "51 87 10 92 52 38 41 A9 SD 23 V3 23 72 58 SE EF 06 8D 35 4C";
@gregfenton
gregfenton / get_firestore_collection_as_json.js
Last active May 16, 2023 17:38
Downloads all docs in a Firestore collection and stores as a JSON file -- command-line JavaScript/node
/**
* get_firestore_collection_as_json.js
*
* This code is a "node script" used to fetch all documents from a Firestore collection,
* either in "the cloud" or the emulator, and write them to a file as JSON.
*
* The script is a "client app", so it logs in with Firebase Auth using email/password from the variable USER1.
* This USER1 user ([email protected]) must exist in your Firebase project and have read access
* to the collection(s) you are populating. You can create that account via
* Firebase Console >> Authentication.