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 time | |
import datetime | |
import pytz | |
def utc_timestamp(dt, tz): | |
tz = pytz.timezone(tz) | |
return int(time.mktime(dt.replace(tzinfo=tz).utctimetuple())) | |
print utc_timestamp(datetime.datetime.now(), 'Europe/Moscow') |
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 -*- | |
import sys | |
from pprint import PrettyPrinter | |
class UnicodePrettyPrinter(PrettyPrinter): | |
"""Unicode-friendly PrettyPrinter | |
Prints: | |
- u'привет' instead of u'\u043f\u0440\u0438\u0432\u0435\u0442' |
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 -*- | |
""" | |
На работе как-то раз появилась довольно стандартная задача: | |
написать генаратор, который отдаёт элементы из некого итератора пачками | |
по n элементов. | |
Дополнительное условие: | |
Не возвращать пустой список на последней итерации (возникает, когда | |
общее количество элементов кратно размеру пачки). | |
В общем, как-то её в тот раз решили, хоть и не слишком красиво. |
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
" Put to .vimrc | |
" Return to last edit position (You want this!) *N* | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif |
NewerOlder