Skip to content

Instantly share code, notes, and snippets.

> db.post.insert({comment: []})
WriteResult({ "nInserted" : 1 })
> db.post.update({}, {$push: {'comment': {text: '1', child:[]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.post.update({}, {$push: {'comment': {text: '2', child:[]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.post.update({}, {$push: {'comment.0.child': {text: '3', child:[]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.post.update({}, {$push: {'comment.0.child.0.child': {text: '4', child:[]}}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
def mongo(filter):
result = list(db.user.find({'name': {'$gt': filter}}).sort('name').limit(100))
parents = set()
for d in result:
parents.add(d['parent'])
parents = db.user.find({'_id': {'$in': list(parents)}})
assert len(result) == 100
def orient(filter):
import vibe.d;
import core.time;
import std.stdio;
TCPConnection[] workers;
bool logging;
shared static this()
{
// 0.403273203 sec
package main
import "fmt"
import "time"
func main() {
start := time.Now().UnixNano()
random-read: (g=0): rw=randread, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1
random-write: (g=0): rw=randwrite, bs=4K-4K/4K-4K/4K-4K, ioengine=sync, iodepth=1
fio-2.1.3
Starting 2 processes
random-read: Laying out IO file(s) (1 file(s) / 1280MB)
random-write: Laying out IO file(s) (1 file(s) / 1280MB)
Jobs: 1 (f=1): [_w] [100.0% done] [0KB/3104KB/0KB /s] [0/776/0 iops] [eta 00m:00s]
random-read: (groupid=0, jobs=1): err= 0: pid=1476: Fri Oct 16 11:24:06 2015
read : io=1280.0MB, bw=24974KB/s, iops=6243, runt= 52484msec
clat (usec): min=50, max=18582, avg=154.99, stdev=149.82
// service = {};
function controller(scope) {
service.todo.get();
// or $todo = service.todo
// or require('todoService', function($todo) {}
};
alight.hooks.directive.push({
code: 'scope',
fn: function() {
var parentScope;
if (this.directive.scope) {
parentScope = this.scope;
if (this.directive.scope === 'root') {
this.scope = parentScope.$new('root');
} else {
this.scope = parentScope.$new(this.directive.scope === 'isolate');
// current
alight.filters.toString = function(exp, scope) {
return function(val) {
return val.toString()
}
}
// new style
alight.filters.toString = function(val, exp, scope) {
return val.toString()
@lega911
lega911 / 1.js
Created December 18, 2015 18:52
alight.filters.throttle = {
init: function(delay, scope) {
this.delay = Number(delay);
this.to = null;
this.scope = scope;
},
onChange: function(value) {
var that;
that = this;
if (this.to) {
@lega911
lega911 / 1.js
Last active December 18, 2015 19:44
alight.filters.toString = function(val, exp, scope) {
return val.toString()
}