Skip to content

Instantly share code, notes, and snippets.

View stephepush's full-sized avatar

Stephen Peters stephepush

View GitHub Profile
@stephepush
stephepush / ShortenedLinkScopingFunction.js
Created January 7, 2022 02:04
Various attempts to get an object to have an incrementing Id property
const fs = require('fs');
const path = require('path');
module.exports = Id =(() => {
let lastId= 0;
return class ShortenedLink {
constructor(url, cutUrl){
this.id = ++lastId
this.url = url;
-- DROP TABLE car_photos;
-- DROP TABLE cars;
CREATE TABLE cars (
car_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
model_year SMALLINT NOT NULL,
make VARCHAR(80) NOT NULL,
model VARCHAR(90) NOT NULL,
miles INTEGER NOT NULL,
@stephepush
stephepush / database.js
Created October 8, 2021 02:21
passport.js using mariadb and mysql2
const mysql = require('mysql2/promise');
const pool = mysql.createPool({
host: 'localhost',
port: 3306,
user: 'admin',
password: 'hello',
database: 'es_starter'
}); //maybe should be const options
@stephepush
stephepush / carModelExcerpt.js
Created September 26, 2021 03:24
Trying to get deleteById methods to work
static deleteById(id) {
return db.query('DELETE FROM cars WHERE car_id = ?', [id])
} //method I'm trying to get working
static fetchAll () {
const options = {
sql:
"SELECT c.car_id, c.model_year, c.make, c.miles, c.color, c.transmission, c.layout, c.engine_type, p.car_id, p.car_photo_url FROM cars c INNER JOIN car_photos p ON c.car_id = p.car_id",
nestTables: true
@stephepush
stephepush / adminController.postAddVehicle.js
Created September 13, 2021 02:12
Excluding model/class properties in express
exports.postAddVehicle = (req, res, next) => {
const model_year = req.body.model_year;
const make = req.body.make;
const model = req.body.model;
const color = req.body.color;
const miles = req.body.miles;
const transmission = req.body.transmission;
const layout = req.body.layout;
const engine_config = req.body.engine_config;
const car_photo_url = null;
@stephepush
stephepush / nextjs console
Created March 10, 2021 05:03
Nextjs console popos
user@pop-os:~/Documents/03-More-React-Hooks-useContext-useReducer-useCallback-useMemo/clip04-Updating-Example-To-Full-Conf-Site$ npm installnpm WARN deprecated mkdirp@0.5.3: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
> @ampproject/toolbox-optimizer@2.6.0 postinstall /home/user/Documents/03-More-React-Hooks-useContext-useReducer-useCallback-useMemo/clip04-Updating-Example-To-Full-Conf-Site/node_modules/@ampproject/toolbox-optimizer
> node lib/warmup.js
Browserslist: caniuse-lite is outdate
@stephepush
stephepush / ImageChangeOnMouseOver.js
Created February 27, 2021 18:31
Hooks Practice Pluralsight
import React from "react";
import ImageToggleOnMouseOver from "../src/ImageToggleOnMouseOver";
const ImageChangeOnMouseOver = () => {
return (
<div>
<ImageToggleOnMouseOver
primaryImg="/static/speakers/bw/bmwFiverbw.jpg"
secondaryImg="/static/speakers/bmwFiver.jpg"
alt="" />
@stephepush
stephepush / Pokecard.js
Created February 21, 2021 04:36
Pokedex
import React, { Component } from "react";
import "./Pokecard.css";
/*important variables */
//const POKE_API = 'https://assets.pokemon.com/assets/cms2/img/pokedex/detail/';
//let padToThree = (number) => (number <= 999 ? `00${number}`.slice(-3): number);
//let imgSrc = `${POKE_API}${padToThree(props.id)}.png`;
/*end of important variables */
@stephepush
stephepush / index.css
Created August 16, 2020 13:06
CSS that hits a wall
body{
font-family: Helvetica;
}
.nav {
width: 100%;
height: 5%;
display: inline-grid;
grid-template-columns: 20% 1fr 1fr 1fr 20%;
}
@stephepush
stephepush / car_item.rb
Created July 30, 2020 19:37
Car dealer Backend Files
#CarItem model
class CarItem < ApplicationRecord
belongs_to :model_info
end