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...
#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 / simple_useEffect_and_async.js
Last active February 26, 2021 17:24
REACT: A simple example of doing asynchronous work inside of a useEffect()
/**
* 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 / c5_code_challenge_week_1.js
Last active February 26, 2021 17:25
JAVASCRIPT: EvolveU C5 coding challenge - week #1 - answers
// 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 / 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 / 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
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 / eas_sync_customer_config.bash
Last active January 4, 2022 20:13
a shell script to clone a git repo into the current EAS build container
#!/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
@gregfenton
gregfenton / AboutAppView.js
Created January 12, 2022 15:32
An "about app" page that displays various Expo constants
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,