Skip to content

Instantly share code, notes, and snippets.

View YuriGor's full-sized avatar
🍒
Making perfect, remember to finish.

Yuri Gor YuriGor

🍒
Making perfect, remember to finish.
View GitHub Profile
@YuriGor
YuriGor / count-docs.js
Created September 24, 2018 12:52
Benchmark for different MongoDB(Mongoose) count all the docs methods. No difference.
// find().count() vs find().limit(1).count() vs count() vs collection.count()
// Purpose was to detect if collections is empty or not. (That's why limit(1) is fine too)
const { performance } = require('perf_hooks');
const fs = require('fs');
const mongoose = require('mongoose');
require('dotenv').config();
const billionUsers = mongoose.model('User', {
n: {
@YuriGor
YuriGor / dg-jsplumb.js
Last active September 3, 2016 21:37 — forked from michiel/dg-jsplumb.js
// based on http://onais-m.blogspot.nl/2014/10/automatic-graph-layout-with-javascript.html
var jsp = jsPlumb.getInstance();
// construct dagre graph from JsPlumb graph
/* global dagre */
var g = new dagre.graphlib.Graph();
g.setGraph({nodesep:30,ranksep:30,marginx:50,marginy:50});
g.setDefaultEdgeLabel(function() { return {}; });
$('.xnode').each(