Skip to content

Instantly share code, notes, and snippets.

View john-raymon's full-sized avatar
🔮
Building

John Raymon john-raymon

🔮
Building
View GitHub Profile
@john-raymon
john-raymon / remove-node-modules.md
Created August 18, 2018 06:41 — forked from lmcneel/remove-node-modules.md
How to remove node_modules after they have been added to a repo

How to remove node_modules

  1. Create a .gitignore file in the git repository if it does not contain one

touch .gitignore 2. Open up the .gitignore and add the following line to the file

node_modules 3. Remove the node_modules folder from the git repository

@john-raymon
john-raymon / checkKeysValues.js
Last active April 23, 2019 03:45
For autoupdate BullFrog
// write a function that returns a boolean indiciating
// whether a whitelisted state key has a value that is different than it's // previous value
const _whitelistedKeys = [
'invoiceName',
// customer details
'customersFullName',
'customersAddress',
'customersCityState',
'customersZipCode',
@john-raymon
john-raymon / PDFInvoice.js
Created April 26, 2019 23:46
Component responsible for rendering PDF document using React-PDF
import React, { Component, PureComponent } from 'react'
import { connect } from 'react-redux'
import { Page, Text, View, Document, StyleSheet, PDFViewer, Image } from '@react-pdf/renderer';
// Utils
import createUUID from '../util/createUUID'
import agent from '../util/agent'
// Images
import logo from '../images/small_logo.png';
@john-raymon
john-raymon / asyncAwait.js
Last active May 14, 2019 01:59
Async/Await Simple Example
async function testAA(startTest = false) {
if (startTest) {
const result = await new Promise((resolve, reject) => {
setTimeout(() => resolve("worked"), 3000)
})
startTest = result
}
return console.log(
startTest
@john-raymon
john-raymon / passportExample.js
Created May 27, 2019 18:51
Logic behind locating user in passport with a emailOrPhoneNumber field, to allow for a proper query object
const test = {
phonenumber : "hello world",
email: "goodbye world"
}
const email = true;
const phoneNumber = true;
document.write(test[
(email ? 'email' : 'phonenumber')
@john-raymon
john-raymon / index.js
Last active June 2, 2019 04:06
Commerce tut
// init commerce below
const commerce = new window
.Commerce(
process.env.REACT_APP_COMMERCEJS_PUBLIC_KEY,
(process.env.NODE_ENV === 'development') ? true : false
);
// pass as prop to App component
ReactDOM.render(<App commerce={commerce} />, document.getElementById('root'));
@john-raymon
john-raymon / constructor_tut.js
Created June 2, 2019 18:31
constructor-commerce
constructor(props) {
super(props)
this.state = {
products: [],
cart: null
}
}
@john-raymon
john-raymon / componentDidMount-commercejs.js
Last active June 3, 2019 00:32
ComponentDidMount App Commerce.js Demo
componentDidMount() {
const {
commerce
} = this.props
if (commerce !== undefined && typeof commerce !== 'undefined') {
// invoke commerce products method to get all products
commerce.Products.list(
(resp) => {
@john-raymon
john-raymon / addProductToCart-commercejs.js
Created June 3, 2019 01:21
Commercejs tut addProductToCart
addProductToCart(productId) {
this.props.commerce.Cart.add({
id: productId,
}, (resp) => {
// if successful update Cart
if (!resp.error) {
this.setState({
cart: resp.cart
})
}