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
otherPropertyAddresses: mixed().when('numOtherProperties', () => {
return array().of(
addressValidator(true).test(
'is-address-matching',
'Address must not match rental property address',
(value, options) => {
const { numRentalProperties, rentalPropertyAddresses } = options.from[1].value;
const { address: otherAddress, city: otherCity, state: otherState, zip: otherZip } = value;
const hasAmatch = numRentalProperties && rentalPropertyAddresses.some(({ address = '', city = '', state = '', zip = '' }) => {
return (otherAddress === address && otherCity === city && otherState === state && otherZip === zip);
@john-raymon
john-raymon / routeDeploy.js
Created March 7, 2021 08:01 — forked from clonn/routeDeploy.js
Node.js with Express, deploy through web hook. this is route part code.
var exec = require('child_process').exec;
var set = function (app) {
app.post('/deploy', function (req, res) {
var feedback;
var branch = 'master';
try {
feedback = JSON.parse(req.body.payload);
{
"id":"ord_eN1ql9rxedwz3y",
"cart_id":"cart_mwDaOdrme0aeDo",
"checkout_token_id":"chkt_LwjBg6y3DPGLew",
"created":1597275873,
"redirect":false,
"customer_reference":"CMMRC-109163",
"status_payment":"paid",
"status_fulfillment":"fulfilled",
"customer":{
@john-raymon
john-raymon / authentication-on-the-web-cheat-sheet.md
Last active November 1, 2023 15:11
Authentication on the Web (Sessions, Cookies, JWT, localStorage, and more)

Authentication

  • authentication: verifying identity (401 Unauthorized)
  • authorization: verifying permissions (403 Forbidden)

Username/password scheme

  • stateful/session-based/cookie-based (i.e. session using a cookie)
  • stateless/token-based (i.e. token using JWT / OAuth / other)
@john-raymon
john-raymon / cart-checkout.vue
Last active December 17, 2019 01:23
CartCheckout example
<template>
<div v-if="cart" class="flex flex-grow-1 flex-column bg-tan-white w-100 pb4">
<div class="flex justify-between mw9 w-100 items-center center pt4 ph4">
<router-link to="/products" class="flex items-center medium-text f6 tracked-mega ttu no-underline dark-gray dim lh-solid">
<div class="arrowIconContainer fill-cherry pr4">
<ArrowIconSvg />
</div>
continue shopping
</router-link>
@john-raymon
john-raymon / App-commercejs-checkout.js
Created June 15, 2019 02:14
App component after implementing checkout flow
import React, { Component, Fragment } from 'react';
// components
import Product from './Product'
import Cart from './Cart'
import Checkout from './Checkout'
class App extends Component {
constructor(props) {
super(props)
@john-raymon
john-raymon / Cart-commercejs.js
Last active June 3, 2019 06:31
Cart Component Commerce.js
import React from 'react';
// components
import LineItem from './LineItem';
function Cart({ cart, removeProductFromCart }) {
if (cart) {
const {
total_items: totalItems,
subtotal,
import React from 'react'
function LineItem({ id, name, quantity, removeProductFromCart }) {
return (
<div className="cart-container__line-item w-100 flex items-center justify-between pb2">
<div className="w-auto pr1">
<p className="tracked ttc f7">
{name} - ({quantity})
</p>
</div>
import React from 'react'
function Product({
id,
is: {
sold_out: soldOut
},
media: {
source
},
@john-raymon
john-raymon / removeProductFromCart-commercejs.js
Created June 3, 2019 02:50
RemoveProductFromCart Commerce.js
removeProductFromCart(lineItemId) {
this.props.commerce.Cart.remove(lineItemId, (resp) => {
// if successful update Cart
if (!resp.error) {
this.setState({
cart: resp.cart
})
}
});
}