Skip to content

Instantly share code, notes, and snippets.

View klen's full-sized avatar

Kirill Klenov klen

View GitHub Profile
def pylint(path, **meta):
""" Pylint code checking.
:return list: List of errors.
"""
from sys import version_info
if version_info > (3, 0):
import logging
logging.warn("Pylint don't supported python3 and will be disabled.")
""" Interfaces for code checking.
"""
from __future__ import absolute_import, with_statement
import _ast
from os import path as op, environ
from .pep8 import BaseReport, StyleGuide
Traceback (most recent call last):
File "pylama/pylint/logilab/astng/scoped_nodes.py", line 284, in getattr
return [self.import_module(name, relative_only=True)]
File "pylama/pylint/logilab/astng/scoped_nodes.py", line 339, in import_module
return MANAGER.astng_from_module_name(absmodname)
File "pylama/pylint/logilab/astng/manager.py", line 133, in astng_from_module_name
return self.astng_from_file(filepath, modname, fallback=False)
File "pylama/pylint/logilab/astng/manager.py", line 104, in astng_from_file
return ASTNGBuilder(self).file_build(filepath, modname)
File "pylama/pylint/logilab/astng/builder.py", line 128, in file_build
@klen
klen / app.js
Last active December 17, 2015 14:58
/*global window */
'use strict';
require('utils/preload');
require('utils/legacy');
var Backbone = require('backbone');
var app = require('objects/app.js');
var bqueue = require('objects/blanks-queue');
var conf = require('utils/conf');
from itertools import product, groupby
print sum([len(tuple(g)) ** 2 for _, g in groupby(sorted(map(sum, product(range(10), repeat=3))))])
from itertools import product
print sum(1 for a, b in product(map(sum, product(range(10), repeat=3)), repeat=2) if a == b)
from aiohttp import CIMultiDict
# ... somewhere ...
request._headers = CIMultiDict(MY_CUSTOM_HEADER='VALUE HERE', MY_OTHER_CUSTOM_HEADER='VALUE HERE', **request.headers)
""" Hello GIL!
"""
from __future__ import print_function
import math
import multiprocessing
import threading
from time import time
import os
import threading
import Queue
class WorkerThread(threading.Thread):
""" A worker thread that takes directory names from a queue, finds all
files in them recursively and reports the result.
Input is done by placing directory names (as strings) into the
@klen
klen / mixin.py
Created November 14, 2012 18:50
Expand user model in Flask-Foundation
# Somewhere in your app (Ex. foundation/base/yourapp/mixin.py
class NameMixin(object):
name = db.Column(db.String(50))