Skip to content

Instantly share code, notes, and snippets.

@dschenkelman
dschenkelman / sample.md
Created November 4, 2015 18:17
Fighting with mongo's query planner

Index

db.{collection}.ensureIndex({ fieldA: 1, "nested.B": 1, "nested.C": 1 })

Bad query

db.{collection}.find({ fieldA: "abc", "nested.B": "123", "nested.C": "456"})

Only uses first two index fields and then individually scans all matching items for "nested.C": 1.

Good query

db.{collection}.find({ fieldA: "abc", "nested": { $elemMatch: { "B": "123", "C": "456" } })

@dschenkelman
dschenkelman / outstart
Created November 24, 2015 18:25
perf script
root@login:/home/vagrant# perf script
# ========
# captured on: Tue Nov 24 10:13:31 2015
# hostname : login
# os release : 3.13.0-57-generic
# perf version : 3.13.11-ckt21
# arch : x86_64
# nrcpus online : 4
# nrcpus avail : 4
# cpudesc : Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz
@dschenkelman
dschenkelman / keybase.md
Created April 7, 2016 13:34
keybase.md

Keybase proof

I hereby claim:

  • I am dschenkelman on github.
  • I am yenkel (https://keybase.io/yenkel) on keybase.
  • I have a public key whose fingerprint is 6955 6E57 3532 5D50 05EE FBF1 75A0 FEFD F7B4 DDAA

To claim this, I am signing this object:

@dschenkelman
dschenkelman / perf-flame-graph-notes.md
Last active June 20, 2016 21:56 — forked from trevnorris/perf-flame-graph-notes.md
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@dschenkelman
dschenkelman / EventAggregator.js
Created October 8, 2016 02:49
JS event aggregator
import * as Rx from 'rx';
const kSubject = Symbol('subject');
export default class EventAggregator {
constructor(){
this[kSubject] = new Rx.Subject();
}
publish(event, payload){
const express = require('express')
const jwt = require('express-jwt');
const dotenv = require('dotenv');
const constants = require('./constants');
const sandcastle = require('sandcastle');
dotenv.config();
const app = express()
const port = constants.PORT