This file contains 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
#!/usr/bin/env python | |
# coding: utf-8 | |
import mongoengine as me | |
from uuid import uuid4 | |
from datetime import datetime | |
class Session(me.Document): | |
meta = {'collection': 'sessions'} |
This file contains 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
# coding: utf-8 | |
from tornado.web import * | |
from tornado.ioloop import IOLoop | |
import tornado.template | |
import mongoengine as me | |
class Image(me.Document): | |
image = me.FileField() |
This file contains 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 register_thread(self, thread, thread_name, started_connect, finished_connect, error_connect = None): | |
"Метод регистрации стандартных потоков." | |
self.threads[thread_name] = thread | |
self.threads[thread_name].started.connect(started_connect) | |
self.threads[thread_name].finished.connect(finished_connect) | |
if error_connect: | |
self.threads[thread_name].error.connect(error_connect) | |
def terminate_thread(self, thread_name = None): | |
"Закрытие потока. Если имя потока отсутствует - закрываются все потоки" |
This file contains 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
# coding: utf-8 | |
from lxml.html import parse | |
import re | |
def get_news(url = None): | |
if url: | |
doc = parse(url) | |
for news in doc.xpath('//*[@id="content"]/div')[0]: | |
if news.attrib.get('class') == 'news_block': |
This file contains 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
require 'Mongo' | |
include mongo | |
conn = MongoClient.new('192.168.1.103') | |
db = conn['test_database'] | |
coll = db['test_collection'] | |
coll.find.each do |x| | |
puts x['_id'].generation_time |
This file contains 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
module A | |
end | |
class B | |
end | |
def f | |
end | |
def f() |
This file contains 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 motor | |
import tornado.gen as gen | |
@gen.coroutine | |
def foo1(): | |
conn = motor.MotorClient().open_sync() | |
db = conn['test'] | |
result = yield gen.Task(db.accounts.find().limit(10).to_list) | |
return result |
This file contains 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
#include "point.h" | |
#include <iostream> | |
using namespace std; | |
int main(){ | |
Point2D p1 = Point2D(10, 20); | |
cout << "Координаты точки p1: "; | |
p1.print_coordinates(); |
This file contains 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
require 'digest' | |
def get_hash(string=nil, file=nil, method='md5') | |
raise RuntimeError if string.nil? && file.nil? | |
method = method.upcase | |
method = Digest.class_eval(method) | |
if string | |
hash = method.hexdigest(string) |
This file contains 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
module Functional | |
def apply(enum) | |
enum.map &self | |
end | |
alias | apply | |
def reduce(enume) | |
enum.inject &self | |
end | |
alias <= reduce |