View encoding.py
## РОДНОЕ ПРЕДСТАВЛЕНИЕ UTF8-СТРОКИ:
>>> [ord(i) for i in 'Бил Гейтс']
[208, 145, 208, 184, 208, 187,
32,
208, 147, 208, 181, 208, 185, 209, 130, 209, 129]
# Что тут происходит:
# * Я перебираю все символы строки через цикл FOR.
View logit-plot.py
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split,GridSearchCV, cross_val_score,StratifiedKFold,validation_curve,learning_curve
from sklearn.metrics import confusion_matrix, f1_score, matthews_corrcoef, precision_recall_curve, auc, classification_report, roc_curve, cohen_kappa_score, make_scorer,accuracy_score,roc_auc_score,precision_score,recall_score, brier_score_loss
from imblearn.ensemble import BalancedBaggingClassifier
from sklearn.tree import DecisionTreeClassifier
from xgboost.sklearn import XGBClassifier
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
View telesport-vod-example
[
{
"content_id": "87fc1328-cde3-40b0-9b9b-ced0498747c4",
"content_url": "https://h2.silatv.ru/highlight/12121/1080.mp4",
"thumbnail": "http://cdn.okultureno.ru/medialibrary/87f/87f2341b53596e8ca592a1e885261ccf/khokkey-_1_.jpg"
"type" : "game",
"channel": "telesport1",
"release_timestamp": 1518421201, // не нужно при наличие start_time & finish_time
"start_time": 1518421200,
"finish_time": 1518429600,
View content_group_dao.py
# -*- coding: utf8 -*-
from __future__ import absolute_import, print_function
import six
class BaseFieldDao(object):
_value = None
_entity = None
View cyrillic2latin_file_renamer.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
# http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python
from __future__ import print_function
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
import errno
View one_line_handler.py
import logging
class OneLineHandler(logging.StreamHandler):
def emit(self, record):
try:
msg = self.format(record)
stream = self.stream
stream.write('\u001b[1000D' + msg)
View pyav_rtmp_example.py
# -*- coding: utf8 -*-
import av
# Откроем ресурс на чтение
input_resource = av.open(
'rtmp://src_stream:1935/play'
)
# Откроем ресурс на запись.
output_resource = av.open(
View aggregate_concat.py
"""
From http://harkablog.com/inside-the-django-orm-aggregates.html
with a couple of fixes.
Usage: MyModel.objects.all().annotate(new_attribute=GroupConcat('related__attribute', separator=':')
"""
from django.db.models import Aggregate
from django.db.models.sql.aggregates import Aggregate as SQLAggregate
View dns_resolver_middleware.py
# -*- coding: utf8 -*-
from __future__ import absolute_import, division, print_function
import socket
from urlparse import urlparse
class DnsResolverMiddleware(object):
"""
View region_tree.py
from apps.genapi import models
class RegionTreeManager(models.Manager):
def handle_qs(self, qs):
not_detailed_query = "not find_in_set('detailed', Options)"
not_deleted_query = "not find_in_set('deleted', Options)"
qs = qs.extra(where=[not_detailed_query, not_deleted_query])