Skip to content

Instantly share code, notes, and snippets.

Avatar

gregfenton

View GitHub Profile
@gregfenton
gregfenton / AboutAppView.js
Created Jan 12, 2022
An "about app" page that displays various Expo constants
View AboutAppView.js
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,
@gregfenton
gregfenton / eas_sync_customer_config.bash
Last active Jan 4, 2022
a shell script to clone a git repo into the current EAS build container
View eas_sync_customer_config.bash
#!/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
View Home.js
import React from "react";
import Login from "../components/Login";
import Landing from "../Pages/Landing";
function Home(props) {
const [user, setUser] = useState();
return (
<div>
{user ?
@gregfenton
gregfenton / simple_useEffect_and_async.js
Last active Feb 26, 2021
REACT: A simple example of doing asynchronous work inside of a useEffect()
View simple_useEffect_and_async.js
/**
* 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" */
@gregfenton
gregfenton / firestore_add_field_to_all_docs_in_collection.js
Last active Dec 12, 2021
FIRESTORE: a node/JavaScript command-line script that visits all docs in a Firestore collection and updates them with the given values (in this example, we set/add an "enabled" field to TRUE) -- uses the Firebase Web SDK v9 API
View firestore_add_field_to_all_docs_in_collection.js
/**
* 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`.
*
@gregfenton
gregfenton / c5_code_challenge_week_1.js
Last active Feb 26, 2021
JAVASCRIPT: EvolveU C5 coding challenge - week #1 - answers
View c5_code_challenge_week_1.js
// 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(
@gregfenton
gregfenton / get_firestore_collection_as_json.js
Last active Dec 12, 2021
FIRESTORE: a node/javascript command-line script to fetch all documents in a Firestore collection and output them to a file as JSON -- uses the Firebase Web SDK v9 API
View get_firestore_collection_as_json.js
/**
* 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 (the.admin.guy@test.com) 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.
View adruino_http_client.c
#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 / .versionrc.js
Last active Nov 10, 2021
EXPO: configuration of standard-version-expo for a code base that has multiple configuration files
View .versionrc.js
/* 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?
@gregfenton
gregfenton / EXPO_BARE_WORKFLOW.md
Last active Feb 26, 2021
EXPO: a description of ejecting an app from Expo Managed Workflow to run & debug it in Android Studio