Skip to content

Instantly share code, notes, and snippets.

View AshleyCoder3's full-sized avatar
๐ŸŽ†
Focusing

Ashley Burns AshleyCoder3

๐ŸŽ†
Focusing
  • Ilion, New York
  • 13:45 (UTC -04:00)
View GitHub Profile
@AshleyCoder3
AshleyCoder3 / Knex-Setup.md
Created October 15, 2021 01:22 — forked from NigelEarle/Knex-Setup.md
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@AshleyCoder3
AshleyCoder3 / anithingButFive.py
Last active October 1, 2021 02:37 — forked from adelazalewski/anithingButFive.py
Python brain teasers
# Given a start integer and an ending integer (both inclusive), write a function that returns the count (not the sum) of all integers in the range (except integers that contain the digit 5).
# Examples:
# csAnythingButFive(1, 5) -> 1, 2, 3, 4, -> 4 (there are 4 integers in the range that do not contain the digit 5)
# csAnythingButFive(1, 9) -> 1, 2, 3, 4, 6, 7, 8, 9 -> 8
# csAnythingButFive(4, 17) -> 4,6,7,8,9,10,11,12,13,14,16,17 -> 12
# Notes:
# The output can contain the digit 5.
@AshleyCoder3
AshleyCoder3 / logger - mw
Created September 7, 2021 21:50
Server logger to be used with Express
// Use as a basic logger middleware in your server
const logger = (req, res, next) => {
const formatUrl = `${req.baseUrl}${req.url}`
const log = `---------------------------
${Date()}
method: ${req.method}
URL: ${formatUrl}
status: ${res.statusCode}
requester IP: ${req.ip} \n************`
@AshleyCoder3
AshleyCoder3 / ErrorMiddleware.js
Created September 7, 2021 20:16
500ErrorMiddleware
//***********************500 error middleware***********//
//eslint-disable-next-line
server.use((err, req, res, next) => {
res.status(err.status || 500).json({
message: err.message,
devMessage: 'Something bad inside the server!'
});
});