This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> 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 }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import vibe.d; | |
import core.time; | |
import std.stdio; | |
TCPConnection[] workers; | |
bool logging; | |
shared static this() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0.403273203 sec | |
package main | |
import "fmt" | |
import "time" | |
func main() { | |
start := time.Now().UnixNano() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// service = {}; | |
function controller(scope) { | |
service.todo.get(); | |
// or $todo = service.todo | |
// or require('todoService', function($todo) {} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alight.filters.toString = function(val, exp, scope) { | |
return val.toString() | |
} |