Skip to content

Instantly share code, notes, and snippets.

@w495
w495 / xadv-sql-1.0.spec
Last active January 25, 2019 14:15
Простой пример spec файла для сборки rpm-пакета.
Name: xadv-sql
##
## Номер версии (значительные изменения)
## Версия должна начинаться с единицы.
##
Version: 1.0
##
## Номер сборки (незначительные изменения)
@w495
w495 / non-trivial-reverse.c
Created January 16, 2019 18:34
Non-trivial reverse with offset and limit
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef unsigned char byte_t;
static const byte_t offset = 1;
static const byte_t limit = 4;
@w495
w495 / psqlcp.app.src
Created July 24, 2012 00:39
Postgresql connection pool with poolboy
{application, psqlcp, [
{description, "Postgresql connection pool with poolboy"},
{vsn, "0.1"},
{applications, [kernel, stdlib]},
{modules, [psqlcp, psqlcp_worker]},
{registered, [psqlcp]},
{mod, {psqlcp, []}},
{env, [
{pools, [
{fk, [
@w495
w495 / hls-checker.py
Created October 22, 2018 22:32
Micro chunk HLS checker
# -*- coding: utf8 -*-
from __future__ import absolute_import, division, print_function
import logging
import sys
import requests
MIN_CHUNK_SIZE = 1.0
@w495
w495 / encoding.py
Last active March 26, 2018 01:39
Почему «Билл Гейтс» превратился в `«Р‘илл Гейтс»` или проблема с кодировками cp1251 и utf8
## РОДНОЕ ПРЕДСТАВЛЕНИЕ UTF8-СТРОКИ:
>>> [ord(i) for i in 'Бил Гейтс']
[208, 145, 208, 184, 208, 187,
32,
208, 147, 208, 181, 208, 185, 209, 130, 209, 129]
# Что тут происходит:
# * Я перебираю все символы строки через цикл FOR.
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
@w495
w495 / telesport-vod-example
Created February 2, 2018 14:11
Требования по VOD API
[
{
"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,
# -*- coding: utf8 -*-
from __future__ import absolute_import, print_function
import six
class BaseFieldDao(object):
_value = None
_entity = None
@w495
w495 / cyrillic2latin_file_renamer.py
Created August 13, 2017 00:48 — forked from etrushkin/cyrillic2latin_file_renamer.py
Cyrillic to Latin File Changer
#!/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
@w495
w495 / dns_resolver_middleware.py
Last active June 21, 2017 00:19
Scrapy downloader middleware class for handling IPv6-only hosts.
# -*- coding: utf8 -*-
from __future__ import absolute_import, division, print_function
import socket
from urlparse import urlparse
class DnsResolverMiddleware(object):
"""