Skip to content

Instantly share code, notes, and snippets.

View charliecalvert's full-sized avatar

Charlie Calvert charliecalvert

View GitHub Profile
@charliecalvert
charliecalvert / knex-create.js
Last active September 15, 2023 21:13
Use Knex and node.js to create a table if it does not exist
/**
* Split out the async/await createTable function into its own method
*
* @param {knex} knex
* @returns {Promise}
*/
async function makeTable(knex) {
console.log("In async method attempting to create table documents");
await knex.schema.createTable('documents', function (table) {
table.increments('id').primary();
@charliecalvert
charliecalvert / set_document.js
Last active February 6, 2023 21:51
basic database operations used with firebase-index.js and sign-in-elf-js included in these gestures
import { getFirestore, doc, setDoc } from "firebase/firestore";
/**
* basic database operations used with firebase-index.js
* and sign-in-elf-js included in these gists
*/
// Add a new document in collection "cities"
async function runSantaCruz(firebaseApp) {
const db = getFirestore(firebaseApp);
@charliecalvert
charliecalvert / firebase-index.js
Last active February 6, 2023 21:45
firebase index file used with sign in elf which is also just on this site. assumes you also want to use the database
// src/index.js
import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore/lite';
import { firebaseConfig } from './configure';
import { runSacramento } from './set_document';
import { signInElf } from './sign-in-elf';
const firebaseApp = initializeApp(firebaseConfig);
const db = getFirestore(firebaseApp);
signInElf(firebaseApp);
@charliecalvert
charliecalvert / sign-in-elf.js
Created February 6, 2023 21:36
firebase sign in help
import { signIn, signOutElf } from './auth_google_signin_popup';
import { getAuth } from "firebase/auth";
function signInElf(firebaseApp) {
const auth = getAuth(firebaseApp);
signInBtn.onclick = () => {
signIn();
}
{
"editor.fontSize": 16,
"editor.accessibilitySupport": "off",
"editor.renderWhitespace": "all",
"workbench.tree.indent": 26,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascriptreact",
@charliecalvert
charliecalvert / elf-tagger.sh
Last active March 1, 2021 18:46
Help with tagging depends on semver-inc
#! /usr/bin/env bash
if [[ -z $2 ]]; then
echo -e "You must pass in a commit message and the project name"
exit
fi
if [[ ! -z $3 ]]; then
echo -e "Too many parameters"
exit
@charliecalvert
charliecalvert / ElfApp.js
Created May 14, 2019 13:38
Default React Class Component
import React, {Component} from 'react';
class ElfApp extends Component {
render() {
return (
<div>
<h1>Welcome to Elf App</h1>
</div>
);
@charliecalvert
charliecalvert / MaterialUiTileDataListItemLink.js
Last active May 9, 2019 16:57
Set up a Material-UI menu without react router DOM.
@charliecalvert
charliecalvert / MaterialUiTileData.js
Last active May 9, 2019 16:14
Tile Data for use with MaterialUiHeader when Using React Router DOM
import React from 'react';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import InboxIcon from '@material-ui/icons/MoveToInbox';
import DraftsIcon from '@material-ui/icons/Drafts';
import StarIcon from '@material-ui/icons/Star';
import SendIcon from '@material-ui/icons/Send';
import { Link } from 'react-router-dom';
@charliecalvert
charliecalvert / MaterialUiElfHeader.js
Last active May 9, 2019 21:08
MaterialUi ElfHeader
import React, { useState } from "react";
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Drawer from '@material-ui/core/Drawer';
import IconButton from '@material-ui/core/IconButton';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import MenuIcon from '@material-ui/icons/Menu';
import Divider from '@material-ui/core/Divider';