Skip to content

Instantly share code, notes, and snippets.

View joeywhelan's full-sized avatar

Joey Whelan joeywhelan

View GitHub Profile
@joeywhelan
joeywhelan / funcExamples.js
Created December 11, 2021 21:59
Javascript Function Argument Options and Object Conditionals
/**
* @fileoverview Various function argument and object constructor examples
* @author Joey Whelan
*/
//base example
function example1(p1,p2,p3) {
console.log('example1');
const params = {
/*jshint esversion: 6 */
'use strict';
'use esversion 6';
const MongoClient = require('mongodb').MongoClient;
const CONNECTION_URL = 'mongodb://admin:mongo@localhost:27017';
const DB_NAME = 'testDB';
const COLLECTION = 'testCollection';
@joeywhelan
joeywhelan / authdemo.js
Created April 17, 2014 00:22
Password Storage with MongoDB and Node
var crypto = require('crypto');
var mongodb = require('mongodb');
var Binary = require('mongodb').Binary;
var userColl = undefined;
var saltLengthBytes = 64;
var hashIterations = 10000;
var keyLengthBytes = 64;
function authenticateUser(id, password, callback)
@joeywhelan
joeywhelan / cryptdemo.js
Last active June 9, 2017 08:31
Node.js Crypto Module Examples
/**
* Joey Whelan
* 3 examples on usage of the node crypto module
*/
var crypto = require('crypto');
var plainText = '1234567812345678';
try
{
@joeywhelan
joeywhelan / TimeStamper
Last active January 1, 2016 22:59
Custom Timestamp function along with how to call it out of winston.
var timeStamper = function()
{
var date = new Date();
var sec = date.getSeconds();
if (sec < 10)
sec = '0' + sec;
var min = date.getMinutes();
if (min < 10)
min = '0' + min;