Skip to content

Instantly share code, notes, and snippets.

View funador's full-sized avatar

Jesse Heaslip funador

View GitHub Profile
// Inside onChange handler
// ....
// #1 There are too many files!
if (files.length > 3) {
const msg = 'Only 3 images can be uploaded at a time'
return this.toast(msg, 'custom', 2000, toastColor)
}
const types = ['image/png', 'image/jpeg', 'image/gif']
app.post('/image-upload-single', (req, res) => {
const path = Object.values(Object.values(req.files)[0])[0].path
cloudinary.uploader.upload(path)
.then(image => res.json([image]))
})
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faTimesCircle } from '@fortawesome/free-solid-svg-icons'
export default props =>
props.images.map((image, i) =>
<div key={i} className='fadein'>
<div
onClick={() => props.removeImage(image.public_id)}
className='delete'
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faImages, faImage } from '@fortawesome/free-solid-svg-icons'
export default props =>
<div className='buttons fadein'>
<div className='button'>
<label htmlFor='single'>
<FontAwesomeIcon icon={faImage} color='#3B5998' size='10x' />
</label>
import React from 'react'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faBowlingBall } from '@fortawesome/free-solid-svg-icons'
export default () =>
<div className='spinner fadein'>
<FontAwesomeIcon icon={faBowlingBall} size='5x' color='#3B5998' />
</div>
require('dotenv').config()
const express = require('express')
const cloudinary = require('cloudinary')
const formData = require('express-form-data')
const cors = require('cors')
const { CLIENT_ORIGIN } = require('./config')
const app = express()
cloudinary.config({
import React, { Component } from 'react'
import Spinner from './Spinner'
import Images from './Images'
import Buttons from './Buttons'
import { API_URL } from './config'
import './App.css'
export default class App extends Component {
state = {
const nums = []
for (let i = 0; i <= 10000; i++) {
nums.push(i)
}
const nums2 = [...nums, 10000]
// previously written functions for duplicates
// duplicates2, duplicates3, duplicates4
const nums = [2, 6, 3, 10]
const nums2 = [2, 4, 1, 2]
const duplicates4 = arr => {
// Start with an empty Object as a
// record keeper
const obj = {}
for (let i = 0; i < arr.length; i++) {
const nums = [2, 6, 3, 10]
const nums2 = [2, 4, 1, 2]
const duplicates3 = arr => {
for (let i = 0; i < arr.length; i++) {
const num = arr[i]
// We take a slice of the remaining Array
// and see if that includes the num
// it must be a duplicate