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 is_dates_intersect(dt1_from, dt1_to, dt2_from, dt2_to): | |
"""Returns True if there is an intersection of datetime ranges.""" | |
first_condition = (dt1_from <= dt2_from <= dt1_to) | |
second_condition = (dt2_from <= dt1_from <= dt2_to) | |
return first_condition or second_condition |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" alternatively, pass a path where Vundle should install plugins | |
"call vundle#begin('~/some/path/here') | |
" let Vundle manage Vundle, required |
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 lxml.etree as ET | |
dom = ET.parse(xml_filename) | |
xslt = ET.parse(xsl_filename) | |
transform = ET.XSLT(xslt) | |
newdom = transform(dom) | |
print(str(newdom)) |
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
1. Книга Эрика Эванса "The Big Blue Book" | |
https://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215 | |
Порядок чтения: https://twitter.com/renoirb/status/248847526910894081?lang=en | |
2. Книга Vaughn Vernon "The Red Book" | |
https://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577 | |
3. Алексей Мерсон — Domain-driven design: рецепт для прагматика. | |
Свежий доклад с очень хорошим объяснением деталей. Упор на моделирование. | |
https://www.youtube.com/watch?v=CR9mLGN9jh0&list=PL48wL0ANkqzTgr6QBblkom0wg7IFXufn0&index=2&t=1990s |
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
#!/bin/bash | |
./youtube-dl --download-archive downloaded.txt -i -o "%(uploader)s/%(upload_date)s - %(title)s - (%(duration)ss) [%(resolution)s].%(ext)s" -f bestvideo[ext=mp4]+bestaudio --batch-file=channel_list.txt | |
# or | |
# usage: youtube_channel_download.sh videourl | |
LOGFILE="$PWD/$(date +"%Y-%m-%d-%H-%M-%S.%N").log" | |
exec 3>&1 4>&2 >>$LOGFILE 2>&1 | |
youtube-dl --verbose --ignore-errors --no-continue --no-overwrites --keep-video --no-post-overwrites --download-archive archive.txt --write-description --write-info-json --write-annotations --write-thumbnail --all-subs --output "%(uploader)s (%(uploader_id)s)/%(id)s/%(title)s - %(upload_date)s.%(ext)s" -f bestvideo[ext=mp4]+bestaudio[ext=m4a] -- $1 |
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
raise type("Hello world :) ", (RuntimeError,), {})() |
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
rotated = zip(*original[::-1]) |
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
""" | |
>>> api_instance = BypassApiKey(RemoteServerApi()) | |
>>> api_instance.method_that_need_access_token(1, 2, 3) | |
[(1, 2, 3), {'access_token': 'test'}] | |
""" | |
import functools | |
ACCESS_TOKEN = 'test' | |
class RemoteServerApi: |
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
#!/bin/sh | |
# usage: cron_git_pull.sh [optional_branch_name] | |
git fetch | |
UPSTREAM=${1:-'@{u}'} | |
LOCAL=$(git rev-parse @) | |
REMOTE=$(git rev-parse "$UPSTREAM") | |
BASE=$(git merge-base @ "$UPSTREAM") | |
if [ $LOCAL = $REMOTE ]; then | |
echo "Up-to-date" |
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
# origin: https://stackoverflow.com/questions/33672412/python-functools-lru-cache-with-class-methods-release-object | |
import functools | |
import weakref | |
def memoized_method(*lru_args, **lru_kwargs): | |
def decorator(func): | |
@functools.wraps(func) | |
def wrapped_func(self, *args, **kwargs): | |
# We're storing the wrapped method inside the instance. If we had | |
# a strong reference to self the instance would never die. |
NewerOlder