Skip to content

Instantly share code, notes, and snippets.

View obbap1's full-sized avatar

Obba Paschal obbap1

View GitHub Profile
/******************** HELPER FUNCTION **********************/
//Filter array for any distinct values --- STACKOVERFLOW
function isDistinct(array) {
return new Set(array).size === array.length;
}
// Use combination sum to get all the possible combinations
function combinationSum(candidates, target) {
var result = [];
@jsdevtom
jsdevtom / index.ts
Created July 29, 2018 14:43
Connect to MongoDB from Google Cloud function best practice through Maintaining Persistent Connections
import {CustomError} from "./error/custom-error.interface";
require('dotenv').config();
import {RequestHandler} from 'express';
import {MongoClient} from 'mongodb';
let client: MongoClient;
const connectToClientIfDropped: () => Promise<void> = async () => {
if (client && client.isConnected()) {