Skip to content

Instantly share code, notes, and snippets.

View jcottam's full-sized avatar

John Ryan Cottam jcottam

View GitHub Profile
@jcottam
jcottam / index.vue
Last active October 11, 2019 11:49
Running NUXT in parallel with Express
<template>
<section class="container">
<h1>
<a
href="https://medium.com/@johnryancottam/running-nuxt-in-parallel-with-express-ffbd1feef83c"
target="_blank"
>Running NUXT in parallel with Express</a
>
</h1>
<div v-if="movie" class="movie">
@jcottam
jcottam / index.js
Created October 11, 2019 11:44
OMDb API endpoint
// OMDb API endpoint
const axios = require('axios')
let movieIndex = 0
app.get('/api/next-movie', async (req, res, next) => {
const movieOptions = [
'tt3896198',
'tt0071253',
'tt0109686',
'tt2267998',
'tt0109040',
@jcottam
jcottam / simple_spec.js
Created August 15, 2018 19:58
Mobile (iPhone 6)
describe('Mobile (iPhone 6)', function() {
beforeEach(function() {
cy.viewport('iphone-6')
cy.visit('/')
})
it('Grid is Responsive, Expect 1 Movie per row', function() {
cy.get('.movie-item')
.should('be.visible')
.and('have.css', 'flex-basis', '100%')
@jcottam
jcottam / simple_spec.js
Created August 15, 2018 19:39
Application UI Tests
describe('Application UI', function() {
beforeEach(function() {
cy.visit('/')
})
it('Verify Application Installation', function() {
cy.get('[data-cy=header]').should('contain', 'Testing with Cypress.io')
})
it('Verify Movie Grid Populates w/ 10 Movies', function() {
@jcottam
jcottam / simple_spec.js
Last active August 15, 2018 19:31
OMDB API Test
describe('OMDB API', function() {
it('Verify OMDB API is Functioning', function() {
cy.request('https://www.omdbapi.com/?i=tt3896198&apikey=9733f1df')
})
})
@jcottam
jcottam / index.html
Last active July 30, 2018 17:55
Progressive Image
<div class="item-container">
<div class="image-container">
<!-- low-quality placeholder -->
<img class="low-quality" src="//res.cloudinary.com/demo/image/fetch/e_blur:1000/e_grayscale,w_400,h_400,q_auto:low/https://unsplash.it/400/400">
<!-- high-quality image -->
<img class="high-quality" src="//unsplash.it/400/400">
</div>
</div>
<style>
@jcottam
jcottam / index.html
Created July 30, 2018 13:49
Progressive Image
<div class="image-container">
<img class="low-quality" src="url-to-low-quality-image.jpg">
<img class="high-quality" src="url-to-high-quality-image.jpg">
</div>
<style>
.image-container{
position:relative;
width:300px;
height:auto;
@jcottam
jcottam / index.js
Created July 25, 2018 15:52
Image Uploading with Node & Cloudinary
app.post('/upload', (req, res, next) => {
const upload = multer({ storage }).single('name-of-input-key')
upload(req, res, function(err) {
if (err) {
return res.send(err)
}
console.log('file uploaded to server')
console.log(req.file)
// SEND FILE TO CLOUDINARY
@jcottam
jcottam / index.js
Last active July 25, 2018 15:49
Image Uploading with Node & Cloudinary
// INDEX.JS
const express = require('express')
const app = express()
// MULTER
const multer = require('multer')
const storage = multer.diskStorage({
destination: function(req, file, cb) {
cb(null, 'uploads/')
},
@jcottam
jcottam / index.js
Last active October 11, 2019 11:39
Running NUXT in parallel with Express
// server/index.js
const express = require('express')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')
const app = express()
// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')
config.dev = process.env.NODE_ENV !== 'production'