Skip to content

Instantly share code, notes, and snippets.

View christkv's full-sized avatar

Christian Amor Kvalheim christkv

View GitHub Profile
I, [2020-01-28T13:04:01.697979 #19] INFO -- : Celluloid 0.17.4 is running in BACKPORTED mode. [ http://git.io/vJf3J ]
DEPRECATION WARNING: Including LoggerSilence is deprecated and will be removed in Rails 6.1. Please use `ActiveSupport::LoggerSilence` instead (called from <top (required)> at /app/config/application.rb:7)
boot.rb :: redis://redistogo:5d409cac6b79ca38e02304d3ead04aec@porgy.redistogo.com:11884/
ENV['REDISTOGO_URL'] = redis://redistogo:5d409cac6b79ca38e02304d3ead04aec@porgy.redistogo.com:11884/
ENV['REDIS_URL'] =
application.rb :: redis://redistogo:5d409cac6b79ca38e02304d3ead04aec@porgy.redistogo.com:11884/
ENV['REDISTOGO_URL'] = redis://redistogo:5d409cac6b79ca38e02304d3ead04aec@porgy.redistogo.com:11884/
ENV['REDIS_URL'] = redis://redistogo:5d409cac6b79ca38e02304d3ead04aec@porgy.redistogo.com:11884/
[2020-01-28T13:04:04 (process) #19][INFO] appsignal: Loading Rails (6.0.1) integration
[2020-01-28T13:04:05 (process) #19][ERROR] appsignal: Push api key not set after loading config
@christkv
christkv / es6 promises and generators
Created March 4, 2016 18:21
es6 promises and generators
var a = new Promise(function(reject, resolve) {
if(err) return reject(err);
.......
resolve(value);
});
var b = new Promise(function(reject, resolve) {
if(err) return reject(err);
.......
resolve(value);

Start Suite: legacy js parser

  • {'hello': 'world', n: 0} x 251,461 ops/sec ±2.07% (86 runs sampled)
  • {'hello': 'world', n: 0, doc: { a: 1}} x 112,596 ops/sec ±1.72% (85 runs sampled)
  • {'hello': 'world', n: 0, doc: { a: 1, b: { 'hello': 'again' }}} x 69,673 ops/sec ±3.34% (86 runs sampled)

Start Suite: legacy c++ parser

  • {'hello': 'world', n: 0} x 645,325 ops/sec ±0.92% (97 runs sampled)
  • {'hello': 'world', n: 0, doc: { a: 1}} x 350,544 ops/sec ±1.40% (95 runs sampled)
var cursor = GLOBAL.db.collection("data").find({ dataId : dataId }, { _id : 1, data : 2 }, { "sort" : [[ '_id', 1 ]] });
cursor.on('data', function(doc) {
});
cursor.on('error', function(err) {
});
cursor.on('end', function() {
});
var ReplSetManager = require('mongodb-tools').ReplSetManager
, ServerManager = require('mongodb-tools').ServerManager
, ShardingManager = require('mongodb-tools').ShardingManager
, mkdirp = require('mkdirp')
, path = require('path');
// Parse the passed in parameters
var yargs = require('yargs')
.usage('Start a local topology.\nUsage: $0')
.example('$0 -t replicaset', 'Run a local replicaset')
var count = items.length;
for(var i = 0; i < items.length; i++) {
doSomething(function(err) {
count = count - 1;
if(count == 0) {
console.log("DONE")
}
var A = function() {
var _a = 1;
this.A = function() {
return _a;
}
}
//
// Ensures that mongod respects the batch write protocols
//
var collectionName = "batch_write_protocol";
var coll = db.getCollection(collectionName);
jsTest.log("Starting insert tests...");
coll.remove({});
@christkv
christkv / gist:3230153
Created August 1, 2012 19:57
A bit simpler
bc = {
auth:{
configuration_type: 'replicaset',
replicaset: {
db_name: 'auth',
servers: [
{host:'localhost',port:4000,options:{auto_reconnect:true}},
{host:'localhost',port:4001,options:{auto_reconnect:true}}
,{host:'localhost',port:4002,options:{auto_reconnect:true}}
],
@christkv
christkv / node_knockout_mongo_2_article
Created August 24, 2011 21:39
A primer for GridFS using the Mongo DB driver
# A primer for GridFS using the Mongo DB driver
In the first tutorial we targeted general usage of the database. But Mongo DB is much more than this. One of the additional very useful features is to act as a file storage system. This is accomplish in Mongo by having a file collection and a chunks collection where each document in the chunks collection makes up a **Block** of the file. In this tutorial we will look at how to use the GridFS functionality and what functions are available.
## A simple example
Let's dive straight into a simple example on how to write a file to the grid using the simplified Grid class.
var mongo = require('mongodb'),
Server = mongo.Server,
Db = mongo.Db,
Grid = mongo.Grid;