Skip to content

Instantly share code, notes, and snippets.

import vibe.d;
import core.time;
import std.stdio;
TCPConnection[] workers;
bool logging;
shared static this()
{
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):
> 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 })
from eps_get import EPS
import core, app # load app
import sys
def call_eps(name):
EPS.system.start()
fn = EPS
for k in name.split('.')[1:]:
curl -X PUT 10.0.3.16:9200/btest -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"my_analyzer" : {
"type" : "custom",
"tokenizer" : "lowercase",
"filter" : ["my_ngram"]
import os
import bottle
os.chdir(os.path.dirname(os.path.abspath(__file__)))
@bottle.route('/')
def index():
return b'Hello world'
application = bottle.default_app()
alight.directives.al.submit2 = function() {
var dir = alight.directives.al.submit.apply(null, arguments); // Создаем родительскую директиву
dir.doCallback = function(e) { // Подменяем метод обновления модели
self.callback();
scope.$scan();
return true;
};
return dir;
}
import threading
import time
from contextlib import contextmanager
@contextmanager
def timeit(exception=Exception):
start = time.time()
yield
print(time.time() - start)
import timeit
import threading
lst = []
def lf():
del lst[:]
for i in range(10000):
lst.append(i)
import timeit
import threading
lst = []
def lf():
for i in range(10000):
lst.append(i)
def f1():