- some item
- another item
- yet another multiline item
- this multiline is expected to be splited
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 requests | |
login = 'asdaf' | |
password = 'afaweef' | |
data = { | |
'USER_LOGIN': login, | |
'USER_PASSWORD': password, | |
'backurl': '/private/', | |
'AUTH_FORM': 'Y', | |
'TYPE': 'AUTH'} |
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
from itertools import repeat, chain | |
def get_dict(keys, values): | |
result = dict() | |
for key, value in zip(keys, chain(values, repeat(None))): | |
result[key] = value | |
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
from re import match, I | |
def login_is_valid_re(login: str): | |
return bool( | |
match('^[a-z][a-z0-9\-\.]{0,19}', login, I) and \ | |
match('[a-z0-9\-\.]{0,19}[a-z0-9]$', login, I) | |
) | |
def login_is_valid(login: str): | |
head = 'abcdefghijklmnopqrstuvwxyz' |
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
SELECT | |
users.name as name, count(*) as counter | |
FROM | |
messages | |
JOIN users | |
ON users.uid = messages.uid | |
GROUP BY messages.uid; |
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 top_10_ip(file_object): | |
result = {} | |
for line in file_object: | |
ip = line.split()[0] | |
if result.setdefault(ip, 1): | |
result[ip] += 1 | |
return sorted(result, key=lambda x: result[x], reverse=True)[:10] |
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 java.security.MessageDigest | |
import akka.util.ByteString | |
import akka.stream.scaladsl.Sink | |
import scala.concurrent.ExecutionContext | |
trait SomeSink { | |
def digest: MessageDigest | |
def sink(implicit ec: ExecutionContext): Sink[ByteString, Future[String]] = | |
Sink.fold[MessageDigest, ByteString](digest) { (digest, chunk) => |
Добро пожаовать в руководство Python Girls! Мы рады здесь тебя видеть :-) В этом руководстве мы дадим базовое представление о разработке на языке Python, посмотрим, как устроены боты в Telegram и попробуем такого своими руками.
Как и с любой незнакомой темой – это будет приключением. Но не волнуйся, тебе уже хватило смелости оказаться здесь, так что всё будет хорошо :)
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 flatten(dictionary, prefix = list(), sep='.'): | |
""" | |
Trivial function designed to make nested JSON suitable for | |
writing as CSV file. | |
>>> flatten( | |
{ | |
'foo': 'bar', | |
'buz': { | |
'foo1': 1, |