Skip to content

Instantly share code, notes, and snippets.

View zacharyhill's full-sized avatar

Zachary Hill zacharyhill

View GitHub Profile
LinkedList.prototype.reverse = function() {
var node = this.head;
var previous = null;
while (node !== null) {
var save = node.next;
node.next = previous;
previous = node;
node = save;
}
var save = this.head;
var generate = function(numRows) {
var rows = [];
for (var row = 1; row <= numRows; row++) {
rows.push([]);
var rowIndex = row - 1;
var numOfItems = row;
for (var itemNum = 1; itemNum <= numOfItems; itemNum++) {
if (itemNum === 1 || itemNum === numOfItems) {
rows[rowIndex].push(1);
[nodemon] 1.14.11
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
express:router:route new '/' +0ms
express:router:layer new '/' +1ms
express:router:route get '/' +1ms
express:router:layer new '/' +0ms
express:router:route new '/login' +0ms
express:router:layer new '/login' +0ms
const fs = require('fs');
const path = require('path');
const s3etm = require('s3-emails-to-mongo');
// MAKE THIS PART DYNAMIC LATER
s3etm.configure({
Bucket: 'zhillb-mail',
});
module.exports = async (req, res, next) => {
@zacharyhill
zacharyhill / login.js
Created January 22, 2018 22:58
Login Controller for Express Route
const bcrypt = require('bcrypt');
// const jwt = require('jsonwebtoken');
const User = require('../models/user');
async function authenticateUser(username, password) {
const users = await User.find({ username });
if (users.length) {
const user = users[0];
const samePassword = await checkPassword(password, user.password);
return samePassword;
const bucket = require('./bucket');
const configure = require('./config');
const db = require('./db');
const parse = require('./parseMail');
let config;
const processNewMail = function(optionalCallback) {
if (config.Bucket === '') {
throw new Error('Bucket name must be set!');
const fs = require('fs');
module.exports.getFiles = function() {
return new Promise((resolve, reject) => {
fs.readFile('/home/usr', (err, data) => {
if (err) {
reject(err);
}
else {
resolve(data);
const defaults = {
Bucket: '',
DB: 'Mail',
Save: {
headers: false,
subject: true,
from: true,
to: true,
cc: true,
bcc: true,
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
var Bucket;
function bucketNameIsUndefined() {
if (!Bucket) {
return true;
function every(array, callbackFunction) {
var doesEveryElementMatch = true;
array.forEach(function(element) {
doesEveryElementMatch = callbackFunction(element);
});
return doesEveryElementMatch;
}