This file contains hidden or 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
""" | |
Simple watchdog which kills the command affter timeout. | |
You can specify the timeout in seconds for kill by env-variable TIMEOUT | |
Example: | |
TIMEOUT=300 python time-keeper.py this-will-hang-up-but-gonna-be-killed-in-5-mins.exe | |
""" | |
import logging | |
import os | |
import subprocess |
This file contains hidden or 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 __future__ import print_function | |
INPUT_FILENAME = 'export_dmr.txt' | |
OUTPUT_FILENAME = 'export_dmr.csv' | |
FIELDS = [ | |
'dmr_transaction_id', | |
'paid_at', | |
'purchase_price', | |
'purchase_currency', | |
'order_price', |
This file contains hidden or 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 __future__ import print_function | |
""" | |
Pre-commit hook for PEP8 styling | |
Works well with flake8==3.0.4 | |
""" | |
__author__ = 'Ivan Styazhkin <[email protected]>' | |
import subprocess | |
import sys |
This file contains hidden or 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
module.exports = { | |
package: null, | |
syntax: "proto2", | |
messages: [{ | |
name: "Msg", | |
syntax: "proto2", | |
fields: [{ | |
rule: "optional", | |
type: "Commands", | |
name: "command_number", |
This file contains hidden or 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
""" | |
Simple watchdog which just restarts the command. | |
You can specify the limit for restarts by env-variable LIMIT | |
Example: | |
LIMIT=10 python watchdog.py this_may_fall.exe | |
""" | |
import logging | |
import os |
This file contains hidden or 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
""" | |
Watchdog which can do one trick only - to sniff for a pattern in a log file and | |
"bark" by running some command. The program won't stop after "barking". | |
Usage: | |
python watch_bro.py <filename> <pattern> <command> | |
filename: A file to watch for changes | |
pattern: A string to look for in the file | |
command: What to execute when the pattern occurs |
This file contains hidden or 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 -*- | |
""" | |
Memento | |
Не нарушая инкапсуляцию, определяет и сохраняет внутреннее состояние объекта и позволяет позже восстановить объект в этом состоянии | |
Chain of responsibility | |
Избегает связывания отправителя запрос с его получателем, давая возможность обработать запрос более чем одному объекту. Связывает объекты-получатели и передает запрос по цепочке пока объект не обработает его | |
Observer |
This file contains hidden or 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 os | |
LOCATION_FILENAME = '.location' | |
TEST_LOCATION = [ | |
[1, 1, 1], | |
[1, 0, 1], |
This file contains hidden or 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 __future__ import print_function | |
import logging | |
class ColoredFormatter(logging.Formatter): | |
""" | |
See more colors and styles at http://stackoverflow.com/a/21786287 | |
""" |
This file contains hidden or 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 datetime | |
import os | |
import sys | |
import subprocess | |
""" | |
Документация по модулю subprocess, который позволяет вызывать другие процессы, | |
писать им в stdin, читать из stdout и stderr, проверять код их завершения | |
https://docs.python.org/2/library/subprocess.html |