Skip to content

Instantly share code, notes, and snippets.

View VonSwirl's full-sized avatar
:octocat:
Working on Private Repos

Jerome Hurley VonSwirl

:octocat:
Working on Private Repos
View GitHub Profile

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
import mongoose from 'mongoose'
/**
* Inherate from another existing mongoose schema
* @param {mongoose.Schema} parentSchema Any existing mongoose.Schema e.g UserSchema
* @param {{}} redefineOrAddFieldsOrEmpty see example below:
* @param {{}} options https://mongoosejs.com/docs/guide.html#options
* * ALLOWS:
* * Modifying Fields
* * Adding Fields
/**
* Compare 2 dates and to find days remaining.
* @param {Date} fromDate This is the starting point date .e.g Date.now()
* @param {Date} toDate A date set ini the future you wish to know how many day remain until.
* @returns {Number} Days remaining between the 2 dates.
* @license MIT https://opensource.org/licenses/MIT
* @author Jerome Hurley
*/
function daysUntilDate (fromDate, toDate) {
const oneDay = 24 * 60 * 60 * 1000
@VonSwirl
VonSwirl / international-currency-codes.js
Last active February 14, 2020 12:41
Currency Codes Nested Objects Javascript ES6
/* eslint-disable camelcase */
/**
* * If you notice anything missing or incorrect please comment. Thanks
* @example
* console.log(currencyCodes_13_11_19.USD.code) // USD
* console.log(currencyCodes_13_11_19.AED.name) // United Arab Emirates Dirham
* console.log(currencyCodes_13_11_19.INR.symbol) // Rs
* console.log(currencyCodes_13_11_19.INR.symbol_native) // ₹
* @license MIT https://opensource.org/licenses/MIT
@VonSwirl
VonSwirl / mongoose-dt-plugin.js
Last active June 26, 2019 10:05
mongoDB mongoose datatables plugin
module.exports = exports = dataTablesPlugin
function dataTablesPlugin (schema, options) {
options = options || {}
var totalKey = options.totalKey || 'total'
var dataKey = options.dataKey || 'data'
var formatters = options.formatters || {}
schema.statics.dataTables = function (params, callback) {
if (typeof params === 'function') {