Skip to content

Instantly share code, notes, and snippets.

View 34fame's full-sized avatar
👨‍💻

Troy Moreland 34fame

👨‍💻
View GitHub Profile
@34fame
34fame / model-db-factory.js
Created September 15, 2022 15:49
Complete code example of functional, factory design pattern implemented in JavaScript
/* Import Libraries */
const { Validator } = require('jsonschema')
const v = new Validator()
/* END Import Libraries */
/* Constants */
const stores = {
FirebaseFirestore: new DbFirebaseFirestoreFactory(),
FirebaseRealtime: () => {},
@34fame
34fame / DesignPatternsUsingFunctionalJavaScript.md
Created September 15, 2022 15:18
Article: Design Patterns Using Functional JavaScript

Design Patterns in JavaScript

Created: June 15, 2022 11:30 AM Last Edited Time: June 19, 2022 4:19 PM Status: In Progress Type: Tech Notes

Problem Statements

  • I am working on a project that is using an SQL database (e.g. PostgreSQL) and the customer decides they want to move to a NoSQL database (e.g. MongooseDb). Now I have to go through my entire project to refactor everything to use this new database.
import Vue from "vue";
import createAuth0Client from "@auth0/auth0-spa-js";
/** Define a default action to perform after authentication */
const DEFAULT_REDIRECT_CALLBACK = () =>
window.history.replaceState({}, document.title, window.location.pathname);
let instance;
/** Returns the current instance of the SDK */
export const getInstance = () => instance;
/** Creates an instance of the Auth0 SDK. If one has already been created, it returns that instance */
export const useAuth0 = ({
@34fame
34fame / translate.js
Created April 29, 2021 06:36
Node script to process translations for Quasar using Google Translate API
const fs = require('fs')
const { Translate } = require('@google-cloud/translate').v2
const locale = require('locale-codes')
const translate = new Translate({
projectId: 'ibofk-dev',
keyFilename: './ibofk-service-account.json'
});
@34fame
34fame / 0-setup.md
Last active April 15, 2021 03:29
Real World Firebase Setup

Setup

Install Packages

# Might require sudo
npm i -g firebase-tools

Project Directories

@34fame
34fame / starter-template.html
Created January 15, 2021 17:06
Using Animate.css
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Custom CSS -->
<style>
.mm-jumbotron {
height: 100vh;
@34fame
34fame / Users.vue
Last active November 10, 2020 16:04
Vue component calling real-time listener
<template>
<div>
<div v-for="user in users" :key="user.id">
{{ JSON.stringify(user) }}
</div>
</div
</template>
<script>
import { mapActions, mapGetters } from 'vuex'
@34fame
34fame / store-users.js
Last active November 10, 2020 15:40
Vuex store example with Firestore real-time updates
import Vue from 'vue'
import { uid } from 'uid'
import { instance as axios } from 'boot/axios'
import { firestore as fs } from 'boot/firebase'
const BASEURL = process.env.API_BASEURL + '/users'
const state = {
collection: {}
@34fame
34fame / boot-firebase.js
Last active June 1, 2021 15:03
Real-time updates from Firestore
import Vue from 'vue'
import firebase from 'firebase/app'
import 'firebase/storage'
import 'firebase/analytics'
import 'firebase/performance'
import 'firebase/firestore'
import 'firebase/auth'
const FIREBASE_CONFIG = {
apiKey: process.env.FIREBASE_APIKEY,
{
infoUrl: {
component: 'q-input',
label: 'Information Link',
model: 'infoUrl',
fieldOptions: {
class: [],
on: {
input: true,
},